Add OBSERVE stats and auto tiny policy profile

This commit is contained in:
Moe Charm (CI)
2025-12-06 01:44:05 +09:00
parent 03538055ae
commit 18faa6a1c4
8 changed files with 182 additions and 144 deletions

View File

@ -13,6 +13,7 @@
#include <stdint.h>
#include <time.h>
#include <string.h>
#include <strings.h>
#include <stdatomic.h>
#define C7_META_COUNTER_DEFINE
#include "core/box/c7_meta_used_counter_box.h"
@ -23,6 +24,8 @@
#include "hakmem.h"
#include "hakmem_build_flags.h"
#include "core/box/c7_meta_used_counter_box.h"
#include "core/box/tiny_class_stats_box.h"
#include "core/box/tiny_class_policy_box.h"
// Box BenchMeta: Benchmark metadata management (bypass hakmem wrapper)
// Phase 15: Separate BenchMeta (slots array) from CoreAlloc (user workload)
@ -256,10 +259,26 @@ int main(int argc, char** argv){
tls_sll_print_measurements();
shared_pool_print_measurements();
// OBSERVE: per-class class stats (thread/global) for policy tuning
const char* stats_dump_env = getenv("HAKMEM_TINY_STATS_DUMP");
const char* policy_profile_env = getenv("HAKMEM_TINY_POLICY_PROFILE");
int policy_is_auto = (policy_profile_env &&
strcasecmp(policy_profile_env, "auto") == 0);
int dump_stats = (stats_dump_env && *stats_dump_env && *stats_dump_env != '0') || policy_is_auto;
if (dump_stats) {
tiny_class_stats_dump_thread(stderr, "[CLASS_STATS_THREAD]");
tiny_class_stats_dump_global(stderr, "[CLASS_STATS_GLOBAL]");
}
// Warm Pool Stats (ENV-gated: HAKMEM_WARM_POOL_STATS=1)
extern void tiny_warm_pool_print_stats_public(void);
tiny_warm_pool_print_stats_public();
if (policy_is_auto) {
tiny_class_policy_refresh_auto();
tiny_class_policy_dump("[POLICY_AUTO]");
}
#if HAKMEM_BUILD_RELEASE
// Minimal Release-side telemetry to verify Warm path usage (C7-only)
extern _Atomic uint64_t g_rel_c7_warm_pop;