// tiny_policy_learner_box.c - Placeholder learner hook #include "tiny_policy_learner_box.h" #include "tiny_class_policy_box.h" #include "tiny_class_stats_box.h" #include // Simple OBSERVE/LEARN rule: // - Choose top-2 classes by shared_pool_lock and enable Page Box for them. // - Always keep existing warm_enabled / warm_cap (policy table is already seeded). void tiny_policy_learner_tick(void) { TinyClassStatsThread snap = {0}; tiny_class_stats_snapshot_global(&snap); int top1 = -1, top2 = -1; uint64_t v1 = 0, v2 = 0; for (int i = 0; i < TINY_NUM_CLASSES; i++) { uint64_t v = snap.shared_lock[i]; if (v > v1) { top2 = top1; v2 = v1; top1 = i; v1 = v; } else if (v > v2) { top2 = i; v2 = v; } } // Nothing observed yet → leave policy untouched if (v1 == 0) { return; } for (int c = 0; c < TINY_NUM_CLASSES; c++) { TinyClassPolicy* p = &g_tiny_class_policy[c]; if (c == top1 || c == top2) { p->page_box_enabled = 1; p->warm_enabled = 1; } } }