## Summary - ChatGPT により bench_profile.h の setenv segfault を修正(RTLD_NEXT 経由に切り替え) - core/box/pool_zero_mode_box.h 新設:ENV キャッシュ経由で ZERO_MODE を統一管理 - core/hakmem_pool.c で zero mode に応じた memset 制御(FULL/header/off) - A/B テスト結果:ZERO_MODE=header で +15.34% improvement(1M iterations, C6-heavy) ## Files Modified - core/box/pool_api.inc.h: pool_zero_mode_box.h include - core/bench_profile.h: glibc setenv → malloc+putenv(segfault 回避) - core/hakmem_pool.c: zero mode 参照・制御ロジック - core/box/pool_zero_mode_box.h (新設): enum/getter - CURRENT_TASK.md: Phase ML1 結果記載 ## Test Results | Iterations | ZERO_MODE=full | ZERO_MODE=header | Improvement | |-----------|----------------|-----------------|------------| | 10K | 3.06 M ops/s | 3.17 M ops/s | +3.65% | | 1M | 23.71 M ops/s | 27.34 M ops/s | **+15.34%** | 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
37 lines
1.4 KiB
C
37 lines
1.4 KiB
C
// tiny_publish.c - Publish aggregator box
|
|
#include "hakmem_tiny.h"
|
|
#include "box/mailbox_box.h"
|
|
#include "tiny_publish.h"
|
|
#include "hakmem_tiny_stats_api.h"
|
|
#include "tiny_debug_ring.h"
|
|
#include "hakmem_trace_master.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
// externs from main TU
|
|
// bench/hot handling remains in core if needed; mailbox publish is always safe
|
|
|
|
void tiny_publish_notify(int class_idx, SuperSlab* ss, int slab_idx) {
|
|
if (__builtin_expect(class_idx < 0 || class_idx >= TINY_NUM_CLASSES, 0)) {
|
|
tiny_debug_ring_record(TINY_RING_EVENT_SUPERSLAB_ADOPT_FAIL, (uint16_t)0xEEu, ss, (uintptr_t)class_idx);
|
|
return;
|
|
}
|
|
g_pub_notify_calls[class_idx]++;
|
|
tiny_debug_ring_record(TINY_RING_EVENT_SUPERSLAB_PUBLISH, (uint16_t)class_idx, ss, (uintptr_t)slab_idx);
|
|
// One-shot visibility trace (env: HAKMEM_TINY_RF_TRACE or HAKMEM_TRACE=refill)
|
|
#if !HAKMEM_BUILD_RELEASE
|
|
static int trace_en = -1;
|
|
if (__builtin_expect(trace_en == -1, 0)) {
|
|
trace_en = hak_trace_check("HAKMEM_TINY_RF_TRACE", "refill");
|
|
}
|
|
if (trace_en) {
|
|
static _Atomic int printed[8];
|
|
int expected = 0;
|
|
if (atomic_compare_exchange_strong(&printed[class_idx], &expected, 1)) {
|
|
fprintf(stderr, "[PUBTRACE] notify class=%d ss=%p slab=%d\n", class_idx, (void*)ss, slab_idx);
|
|
}
|
|
}
|
|
#endif
|
|
mailbox_box_publish(class_idx, ss, slab_idx);
|
|
}
|