Tiny: add per-class refill count tuning infrastructure (ChatGPT)
External AI (ChatGPT Pro) implemented hierarchical refill count tuning:
- Move getenv() from hot path to init (performance hygiene)
- Add per-class granularity: global → hot/mid → per-class precedence
- Environment variables:
* HAKMEM_TINY_REFILL_COUNT (global default)
* HAKMEM_TINY_REFILL_COUNT_HOT (classes 0-3)
* HAKMEM_TINY_REFILL_COUNT_MID (classes 4-7)
* HAKMEM_TINY_REFILL_COUNT_C{0..7} (per-class override)
Performance impact: Neutral (no tuning applied yet, default=16)
- Larson 4-thread: 4.19M ops/s (unchanged)
- No measurable overhead from init-time parsing
Code quality improvement:
- Better separation: hot path reads plain ints (no syscalls)
- Future-proof: enables A/B testing per size class
- Documentation: ENV_VARS.md updated
Note: Per Ultrathink's advice, further tuning deferred until bottleneck
visualization (superslab_refill branch analysis) is complete.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: ChatGPT <external-ai@openai.com>
This commit is contained in:
@ -191,6 +191,12 @@ static inline __attribute__((always_inline)) void ss_active_inc(SuperSlab* ss) {
|
||||
}
|
||||
// EXTRACTED: ss_active_dec_one() moved to hakmem_tiny_superslab.h (Phase 2C-2)
|
||||
|
||||
// Front refill count global config (declare before init.inc uses them)
|
||||
extern int g_refill_count_global;
|
||||
extern int g_refill_count_hot;
|
||||
extern int g_refill_count_mid;
|
||||
extern int g_refill_count_class[TINY_NUM_CLASSES];
|
||||
|
||||
// Step 3d: Forced inlining for slow path (maintain monolithic performance)
|
||||
// Phase 6-1.7: Export for box refactor (Box 5 needs access from hakmem.c)
|
||||
#ifdef HAKMEM_TINY_PHASE6_BOX_REFACTOR
|
||||
@ -1537,6 +1543,13 @@ TinySlab* hak_tiny_owner_slab(void* ptr) {
|
||||
// Box 6: Free Fast Path (Layer 2 - 2-3 instructions)
|
||||
#include "tiny_free_fast.inc.h"
|
||||
|
||||
// ---------------- Refill count (Front) global config ----------------
|
||||
// Parsed once at init; hot path reads plain ints (no getenv).
|
||||
int g_refill_count_global = 0; // HAKMEM_TINY_REFILL_COUNT
|
||||
int g_refill_count_hot = 0; // HAKMEM_TINY_REFILL_COUNT_HOT
|
||||
int g_refill_count_mid = 0; // HAKMEM_TINY_REFILL_COUNT_MID
|
||||
int g_refill_count_class[TINY_NUM_CLASSES] = {0}; // HAKMEM_TINY_REFILL_COUNT_C{0..7}
|
||||
|
||||
// Export wrapper functions for hakmem.c to call
|
||||
// Phase 6-1.7 Optimization: Remove diagnostic overhead, rely on LTO for inlining
|
||||
void* hak_tiny_alloc_fast_wrapper(size_t size) {
|
||||
|
||||
Reference in New Issue
Block a user