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
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// Factory defaults (“balanced”) – mutable at runtime
|
2025-11-11 21:49:05 +09:00
|
|
|
|
// Small classes (0..2) are given higher caps by default to favor hot small-size throughput.
|
2025-11-05 12:31:14 +09:00
|
|
|
|
static const uint16_t k_fast_cap_defaults_factory[TINY_NUM_CLASSES] = {
|
2025-11-11 21:49:05 +09:00
|
|
|
|
256, // Class 0: 8B (was 128)
|
|
|
|
|
|
256, // Class 1: 16B (was 128)
|
|
|
|
|
|
256, // Class 2: 32B (was 128)
|
2025-11-05 12:31:14 +09:00
|
|
|
|
128, // Class 3: 64B (reduced from 512 to limit RSS)
|
|
|
|
|
|
128, // Class 4: 128B (trimmed via ACE/TLS caps)
|
2025-11-11 21:49:05 +09:00
|
|
|
|
224, // Class 5: 256B (bench-optimized default)
|
2025-11-05 12:31:14 +09:00
|
|
|
|
128, // Class 6: 512B
|
2025-11-10 00:25:02 +09:00
|
|
|
|
48 // Class 7: 1KB (reduce superslab reliance)
|
2025-11-05 12:31:14 +09:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t g_fast_cap_defaults[TINY_NUM_CLASSES] = {
|
2025-11-11 21:49:05 +09:00
|
|
|
|
256, 256, 256, 128, 128, 224, 128, 48
|
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
|
|
|
|
|
|
int tiny_default_cap(int class_idx) {
|
|
|
|
|
|
switch (class_idx) {
|
|
|
|
|
|
case 0: return 128; // 8B
|
|
|
|
|
|
case 1: return 128; // 16B
|
|
|
|
|
|
case 2: return 128; // 32B
|
|
|
|
|
|
case 3: return 128; // 64B (reduced from 512 to limit RSS)
|
|
|
|
|
|
case 4: return 96; // 128B (aggressively trimmed to limit RSS)
|
|
|
|
|
|
case 5: return 128; // 256B
|
|
|
|
|
|
case 6: return 128; // 512B
|
|
|
|
|
|
default: return 64; // 1KB
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
int tiny_cap_max_for_class(int class_idx) {
|
|
|
|
|
|
switch (class_idx) {
|
|
|
|
|
|
case 0: return 2048;
|
|
|
|
|
|
case 1: return 1024;
|
|
|
|
|
|
case 2: return 768;
|
|
|
|
|
|
case 3: return 512;
|
|
|
|
|
|
case 4: return 160;
|
|
|
|
|
|
case 5: return 256;
|
|
|
|
|
|
case 6: return 128;
|
|
|
|
|
|
default: return 64;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|