Files
hakmem/core/tiny_publish.c
Moe Charm (CI) 7d0782d5b6 ENV Cleanup Step 17: Gate HAKMEM_TINY_RF_TRACE
Gate the refill trace debug variable behind #if !HAKMEM_BUILD_RELEASE:
- HAKMEM_TINY_RF_TRACE: Controls refill/mailbox publish path tracing
- File: core/tiny_publish.c:21-34 (1 call site gated)

Other 2 call sites already gated:
- core/tiny_refill.h:94 (already inside #if !HAKMEM_BUILD_RELEASE)
- core/box/mailbox_box.c:64 (already inside #if !HAKMEM_BUILD_RELEASE)

Performance: 30.7M ops/s avg (baseline maintained, 3 runs: 30.6M, 30.9M, 30.7M)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 04:36:37 +09:00

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 <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)
#if !HAKMEM_BUILD_RELEASE
static int trace_en = -1;
if (__builtin_expect(trace_en == -1, 0)) {
const char* e = getenv("HAKMEM_TINY_RF_TRACE");
trace_en = (e && atoi(e) != 0) ? 1 : 0;
}
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);
}