Phase POOL-MID-DN-BATCH Step 1: ENV gate for deferred inuse_dec
This commit is contained in:
25
core/box/pool_mid_inuse_deferred_env_box.h
Normal file
25
core/box/pool_mid_inuse_deferred_env_box.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// pool_mid_inuse_deferred_env_box.h — Box: Deferred inuse_dec ENV gate
|
||||||
|
// HAKMEM_POOL_MID_INUSE_DEFERRED=1 (default 0)
|
||||||
|
//
|
||||||
|
// Purpose: ENV-based runtime toggle for deferred inuse_dec optimization
|
||||||
|
// Pattern: Static cached ENV check with __builtin_expect
|
||||||
|
// Phase: POOL-MID-DN-BATCH Step 1
|
||||||
|
|
||||||
|
#ifndef POOL_MID_INUSE_DEFERRED_ENV_BOX_H
|
||||||
|
#define POOL_MID_INUSE_DEFERRED_ENV_BOX_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// Check if deferred inuse_dec is enabled via ENV
|
||||||
|
// Default: 0 (disabled) for safety
|
||||||
|
// Set HAKMEM_POOL_MID_INUSE_DEFERRED=1 to enable
|
||||||
|
static inline int hak_pool_mid_inuse_deferred_enabled(void) {
|
||||||
|
static int g = -1;
|
||||||
|
if (__builtin_expect(g == -1, 0)) {
|
||||||
|
const char* e = getenv("HAKMEM_POOL_MID_INUSE_DEFERRED");
|
||||||
|
g = (e && *e == '1') ? 1 : 0;
|
||||||
|
}
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // POOL_MID_INUSE_DEFERRED_ENV_BOX_H
|
||||||
Reference in New Issue
Block a user