fix(v3): the DoE row's cache and bucket hits are measured, not written as 0 (#142)
Captain Bob, 2026-11-12: "correct deficiencies". heartbeat_capture_tick_snapshot
wrote cache_hits_delta and bucket_hits_delta as 0 ("TODO: wire ..."), though
physics_hotwords_cache.c counts both. Now each is read from the VM's hot-words
cache as a delta since the previous tick, the way word_executions_delta is
(and after the cache's stats are reset, the count since then); a VM with no
cache has 0. word_executions_delta was measured already: doe_log.c's "TODO: 0"
for it was stale, and its three column notes are corrected.
kernel/tests/test_heartbeat_export.c, 4 checks: a VM in memory with a cache
whose counters the test sets, captured tick by tick. Against the code as it
was: 3 failures (the hits 0 where the cache counted 5 and 3, then 7 and 7).
Now: 0. Built for amd64, aarch64, riscv64 and the hosted v3. Shared v3 code,
under the ruling. v3 is not part of acceptance; no DoE has run since 2026-09-16.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
*/
|
||||
|
||||
#include "vm.h"
|
||||
#include "physics_hotwords_cache.h"
|
||||
#include "log.h"
|
||||
#include "platform_time.h"
|
||||
#include <stdio.h>
|
||||
@@ -78,9 +79,19 @@ void heartbeat_capture_tick_snapshot(VM* vm, HeartbeatTickSnapshot* snapshot)
|
||||
/* Delta metrics — computed from per-VM counters using static last-value tracking.
|
||||
* On VM reset (current < last), treat current value as the full delta. */
|
||||
|
||||
/* Cache metrics from hotwords cache */
|
||||
snapshot->cache_hits_delta = 0; /* TODO: wire hotwords cache hit counter */
|
||||
snapshot->bucket_hits_delta = 0; /* TODO: wire bucket hit counter */
|
||||
/* Cache metrics from the hot-words cache's own counters (physics_hotwords_cache.c counts every
|
||||
* cache hit and bucket hit), as deltas since the previous tick -- the same way as
|
||||
* word_executions_delta below. They were written as 0, unmeasured (#142). A VM with no cache
|
||||
* has none. */
|
||||
{
|
||||
static uint64_t last_cache_hits = 0, last_bucket_hits = 0;
|
||||
uint64_t ch = vm->hotwords_cache ? vm->hotwords_cache->stats.cache_hits : 0;
|
||||
uint64_t bh = vm->hotwords_cache ? vm->hotwords_cache->stats.bucket_hits : 0;
|
||||
snapshot->cache_hits_delta = (uint32_t)(ch >= last_cache_hits ? ch - last_cache_hits : ch);
|
||||
snapshot->bucket_hits_delta = (uint32_t)(bh >= last_bucket_hits ? bh - last_bucket_hits : bh);
|
||||
last_cache_hits = ch;
|
||||
last_bucket_hits = bh;
|
||||
}
|
||||
|
||||
/* Word execution delta — words executed since the previous heartbeat tick.
|
||||
* vm->heartbeat.words_executed is incremented by vm_core.c on every dispatch. */
|
||||
|
||||
Reference in New Issue
Block a user