Add Page Box layer for C7 class optimization
- Implement tiny_page_box.c/h: per-thread page cache between UC and Shared Pool - Integrate Page Box into Unified Cache refill path - Remove legacy SuperSlab implementation (merged into smallmid) - Add HAKMEM_TINY_PAGE_BOX_CLASSES env var for selective class enabling - Update bench_random_mixed.c with Page Box statistics Current status: Implementation safe, no regressions. Page Box ON/OFF shows minimal difference - pool strategy needs tuning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -43,9 +43,40 @@ static inline uint32_t xorshift32(uint32_t* s){
|
||||
|
||||
int main(int argc, char** argv){
|
||||
int cycles = (argc>1)? atoi(argv[1]) : 10000000; // total ops (10M for steady-state measurement)
|
||||
int ws = (argc>2)? atoi(argv[2]) : 8192; // working-set slots
|
||||
int ws = (argc>2)? atoi(argv[2]) : 8192; // working-set slots
|
||||
uint32_t seed = (argc>3)? (uint32_t)strtoul(argv[3],NULL,10) : 1234567u;
|
||||
|
||||
// サイズレンジ(Tiny-only / Non-Tiny-only の比較用)
|
||||
// 既定: 16..1040 bytes(元の挙動と同等)
|
||||
size_t min_size = 16u;
|
||||
size_t max_size = 16u + 0x3FFu; // 16..1040 ≒ 16..1024
|
||||
|
||||
// 優先順位: argv[4]/argv[5] → ENV → 既定
|
||||
if (argc > 4) {
|
||||
long v = atol(argv[4]);
|
||||
if (v > 0) min_size = (size_t)v;
|
||||
} else {
|
||||
const char* e = getenv("HAKMEM_BENCH_MIN_SIZE");
|
||||
if (e && *e) {
|
||||
long v = atol(e);
|
||||
if (v > 0) min_size = (size_t)v;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 5) {
|
||||
long v = atol(argv[5]);
|
||||
if (v > 0) max_size = (size_t)v;
|
||||
} else {
|
||||
const char* e = getenv("HAKMEM_BENCH_MAX_SIZE");
|
||||
if (e && *e) {
|
||||
long v = atol(e);
|
||||
if (v > 0) max_size = (size_t)v;
|
||||
}
|
||||
}
|
||||
|
||||
if (min_size < 1) min_size = 1;
|
||||
if (max_size < min_size) max_size = min_size;
|
||||
|
||||
if (cycles <= 0) cycles = 1;
|
||||
if (ws <= 0) ws = 1024;
|
||||
|
||||
@ -79,6 +110,8 @@ int main(int argc, char** argv){
|
||||
slots[idx] = NULL;
|
||||
} else {
|
||||
size_t sz = 16u + (r & 0x3FFu);
|
||||
if (sz < min_size) sz = min_size;
|
||||
if (sz > max_size) sz = max_size;
|
||||
void* p = malloc(sz);
|
||||
if (p) {
|
||||
((unsigned char*)p)[0] = (unsigned char)r;
|
||||
@ -115,7 +148,9 @@ int main(int argc, char** argv){
|
||||
slots[idx] = NULL;
|
||||
warmup_frees++;
|
||||
} else {
|
||||
size_t sz = 16u + (r & 0x3FFu); // 16..1040 bytes
|
||||
size_t sz = 16u + (r & 0x3FFu); // 16..1040 bytes(後段でクランプ)
|
||||
if (sz < min_size) sz = min_size;
|
||||
if (sz > max_size) sz = max_size;
|
||||
void* p = malloc(sz);
|
||||
if (p) {
|
||||
((unsigned char*)p)[0] = (unsigned char)r;
|
||||
@ -151,9 +186,11 @@ int main(int argc, char** argv){
|
||||
}
|
||||
slots[idx] = NULL;
|
||||
frees++;
|
||||
} else {
|
||||
// 16..1024 bytes (power-of-two-ish skew)
|
||||
size_t sz = 16u + (r & 0x3FFu); // 16..1040 (approx 16..1024)
|
||||
} else {
|
||||
// 16..1024 bytes (power-of-two-ish skew, thenクランプ)
|
||||
size_t sz = 16u + (r & 0x3FFu); // 16..1040 (approx 16..1024)
|
||||
if (sz < min_size) sz = min_size;
|
||||
if (sz > max_size) sz = max_size;
|
||||
if (0 && i > 28300) { // DISABLED (Phase 2 perf)
|
||||
fprintf(stderr, "[MALLOC] i=%d sz=%zu idx=%d\n", i, sz, idx);
|
||||
fflush(stderr);
|
||||
|
||||
Reference in New Issue
Block a user