2025-11-05 12:31:14 +09:00
|
|
|
|
/**
|
|
|
|
|
|
* hakmem_tiny_config.c
|
|
|
|
|
|
*
|
|
|
|
|
|
* Implementation of centralized Tiny configuration constants
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "hakmem_tiny_config.h"
|
|
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
// Fast Cache Configuration
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
2025-11-13 14:25:54 +09:00
|
|
|
|
// Factory defaults ("aggressive") – mutable at runtime
|
|
|
|
|
|
// Phase 10: Aggressive cache sizing to maximize TLS hit rate
|
|
|
|
|
|
// Hot classes (C0-C3) get 2-4x larger caches to reduce backend transitions
|
2025-11-05 12:31:14 +09:00
|
|
|
|
static const uint16_t k_fast_cap_defaults_factory[TINY_NUM_CLASSES] = {
|
2025-11-13 14:25:54 +09:00
|
|
|
|
512, // Class 0: 8B (2x increase: hot class)
|
|
|
|
|
|
512, // Class 1: 16B (2x increase: hot class)
|
|
|
|
|
|
512, // Class 2: 32B (2x increase: hot class)
|
|
|
|
|
|
384, // Class 3: 64B (3x increase: hot class)
|
|
|
|
|
|
256, // Class 4: 128B (2x increase: medium class)
|
|
|
|
|
|
384, // Class 5: 256B (1.7x increase: bench-optimized)
|
|
|
|
|
|
192, // Class 6: 512B (1.5x increase)
|
|
|
|
|
|
96 // Class 7: 1KB (2x increase: reduce superslab reliance)
|
2025-11-05 12:31:14 +09:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t g_fast_cap_defaults[TINY_NUM_CLASSES] = {
|
2025-11-13 14:25:54 +09:00
|
|
|
|
512, 512, 512, 384, 256, 384, 192, 96
|
2025-11-05 12:31:14 +09:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void tiny_config_reset_defaults(void) {
|
|
|
|
|
|
for (int i = 0; i < TINY_NUM_CLASSES; i++) {
|
|
|
|
|
|
g_fast_cap_defaults[i] = k_fast_cap_defaults_factory[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
// TLS Magazine Configuration
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// Default TLS magazine capacities per class
|
2025-11-13 14:25:54 +09:00
|
|
|
|
// Phase 10: Aggressive cache sizing for hot classes (C0-C3)
|
|
|
|
|
|
// Goal: Maximize TLS hit rate, reduce backend transitions
|
2025-11-05 12:31:14 +09:00
|
|
|
|
int tiny_default_cap(int class_idx) {
|
|
|
|
|
|
switch (class_idx) {
|
2025-11-13 14:25:54 +09:00
|
|
|
|
case 0: return 512; // 8B (4x increase: hot class)
|
|
|
|
|
|
case 1: return 512; // 16B (4x increase: hot class)
|
|
|
|
|
|
case 2: return 512; // 32B (4x increase: hot class)
|
|
|
|
|
|
case 3: return 384; // 64B (3x increase: hot class)
|
|
|
|
|
|
case 4: return 192; // 128B (2x increase: medium class)
|
|
|
|
|
|
case 5: return 256; // 256B (2x increase: medium class)
|
|
|
|
|
|
case 6: return 192; // 512B (1.5x increase)
|
|
|
|
|
|
default: return 128; // 1KB (2x increase)
|
2025-11-05 12:31:14 +09:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Alias for tiny_default_cap
|
|
|
|
|
|
int tiny_mag_default_cap(int class_idx) {
|
|
|
|
|
|
return tiny_default_cap(class_idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Maximum allowed TLS magazine capacities per class
|
2025-11-13 14:25:54 +09:00
|
|
|
|
// Phase 10: Raise ceilings to allow aggressive cache growth
|
2025-11-05 12:31:14 +09:00
|
|
|
|
int tiny_cap_max_for_class(int class_idx) {
|
|
|
|
|
|
switch (class_idx) {
|
2025-11-13 14:25:54 +09:00
|
|
|
|
case 0: return 4096; // 8B (2x increase: allow massive caching)
|
|
|
|
|
|
case 1: return 4096; // 16B (4x increase: hot class)
|
|
|
|
|
|
case 2: return 2048; // 32B (2.67x increase: hot class)
|
|
|
|
|
|
case 3: return 1536; // 64B (3x increase: hot class)
|
|
|
|
|
|
case 4: return 512; // 128B (3.2x increase: medium class)
|
|
|
|
|
|
case 5: return 768; // 256B (3x increase: medium class)
|
|
|
|
|
|
case 6: return 384; // 512B (3x increase)
|
|
|
|
|
|
default: return 256; // 1KB (4x increase)
|
2025-11-05 12:31:14 +09:00
|
|
|
|
}
|
|
|
|
|
|
}
|