feat(v4): Phase 7 Task 3, first step -- each node's tick by execution, as v3 (#189)
Captain Bob, 2026-11-13: "By execution, as v3". v3's kernel runs a VM's heartbeat cycle every 256 word executions (HEARTBEAT_CHECK_FREQUENCY, vm_core.c:912 and :1210), and its tick_count is the count of cycles. Task 2a had used the kernel's timer heartbeat as the decay clock: corrected. Each node counts its word calls; every 256th runs its heartbeat cycle at the call; the cycle's loops follow. The kernel no longer gives the mesh its timer. Test first: test_mesh_boot.c, 59 checks (67 with pipelining and the cache on). Not pushed (held to the end of Phase 7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
+15
-2
@@ -340,6 +340,13 @@ static void pipeline(unsigned place, v4_mesh_physics *p, uint32_t id)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* a node's heartbeat cycle (v3's vm_heartbeat_run_cycle): its tick; the per-tick loops follow (Task 3) */
|
||||
static void heartbeat_cycle(unsigned place, v4_mesh_physics *p)
|
||||
{
|
||||
(void)place;
|
||||
p->tick++;
|
||||
}
|
||||
|
||||
/* at `call` (exec.h), on a word -- any other target, nothing -- in v3's order (physics_pre_execute,
|
||||
* V3-PARITY.md 2.1; Captain Bob, 2026-11-13: "Every call, as v3"): decay by the ticks since, heat +1,
|
||||
* the count the Stadium is charged by, the temperature, the rolling window */
|
||||
@@ -354,7 +361,6 @@ static void on_call(void *ctx, v4_node *n, v4_cell target)
|
||||
a = &accounts_of(place)[id];
|
||||
if (the->physics) {
|
||||
v4_mesh_physics *p = &the->physics[place];
|
||||
if (the->ticks) p->tick = the->ticks();
|
||||
decay(a, p, p->tick - a->last_decay_tick);
|
||||
a->last_decay_tick = p->tick;
|
||||
a->heat++;
|
||||
@@ -370,6 +376,12 @@ static void on_call(void *ctx, v4_node *n, v4_cell target)
|
||||
if (p->l1_cache && a->heat > V4_MESH_HOT_HEAT && !hot_has(place, target)) promote(place, target);
|
||||
#endif
|
||||
p->prev_id = (uint32_t)id;
|
||||
/* the heartbeat, by execution (v3: every HEARTBEAT_CHECK_FREQUENCY words its VM executes;
|
||||
* Captain Bob, 2026-11-13: "By execution, as v3") */
|
||||
if (++p->check_counter >= p->cycle_every) {
|
||||
p->check_counter = 0;
|
||||
heartbeat_cycle(place, p);
|
||||
}
|
||||
}
|
||||
a->calls++;
|
||||
a->since++;
|
||||
@@ -419,11 +431,12 @@ static void words_attach(unsigned place, v4_fabric_node *x)
|
||||
}
|
||||
if (the->physics) { /* the node's physics, as v3's VM starts */
|
||||
v4_mesh_physics *p = &the->physics[place];
|
||||
uint64_t tick = p->tick; /* the heartbeat's, which goes on */
|
||||
uint64_t tick = 0; /* its own count of cycles, from none */
|
||||
unsigned char *z = (unsigned char *)p;
|
||||
unsigned long i;
|
||||
for (i = 0; i < sizeof *p; i++) z[i] = 0;
|
||||
p->tick = tick;
|
||||
p->cycle_every = V4_MESH_CHECK_FREQUENCY;
|
||||
p->decay_slope_q48 = V4_MESH_INITIAL_DECAY_SLOPE_Q48;
|
||||
p->l3_decay = 1;
|
||||
p->l2_window = 1; /* v3: "No config yet: recorded" */
|
||||
|
||||
Reference in New Issue
Block a user