soul: per-tick arena bracketing in awareness_run + hand-patched dist/soul.c
awareness_run's while-loop ran outside any request arena, so every allocation in every 1s tick (search JSON, heartbeat payloads, curiosity activations) was treated as permanent by the runtime — 7.5GB RSS in under a minute. Bracket each iteration with el_arena_push/el_arena_pop (same pattern the compiler emits for scoped blocks; state_set/state_get persist separately via el_strdup_persist and are unaffected). dist/soul.c carries the same change hand-patched at the compiled awareness_run site — elc is currently unsafe to run locally (pathological memory on sessions.el), so the generated C was patched to match the source, verified line-for-line against the compiler's own conventions. MUST be paired with el repo PR #64 (el_strdup_persist for stored engram fields): per-tick arena reclamation widens the write-corruption window without it. Verified together: 5h live soak on the recovered production snapshot, flat RSS, write-field-integrity clean. Note: dist/soul.c still needs a full elc regen to pick up PR #73's source changes (consent tiers) — tracked separately; this patch does not regress that (those changes were never in dist).
This commit is contained in:
+9
@@ -26214,9 +26214,17 @@ el_val_t awareness_run(void) {
|
||||
el_val_t beat_ms = ({ el_val_t _if_result_103 = 0; if (str_eq(beat_ms_raw, EL_STR(""))) { _if_result_103 = (60000); } else { _if_result_103 = (str_to_int(beat_ms_raw)); } _if_result_103; });
|
||||
el_val_t scan_ms = (beat_ms / 2);
|
||||
while (1) {
|
||||
/* Arena-scope each tick — see awareness.el's el_arena_push/el_arena_pop
|
||||
* around this loop body for the rationale (hand-patched translation of
|
||||
* that source change; el_runtime.c has no existing generated-code
|
||||
* precedent for these two builtins, only the compiler's own internal
|
||||
* usage — mirrors this function's standard zero-arg/one-arg native call
|
||||
* codegen pattern, e.g. state_get()/ise_post() below). */
|
||||
el_val_t tick_mark = el_arena_push();
|
||||
el_val_t running = state_get(EL_STR("soul.running"));
|
||||
if (str_eq(running, EL_STR("false"))) {
|
||||
println(EL_STR("[awareness] exiting"));
|
||||
el_arena_pop(tick_mark);
|
||||
return EL_STR("");
|
||||
}
|
||||
el_val_t did_work = one_cycle();
|
||||
@@ -26264,6 +26272,7 @@ el_val_t awareness_run(void) {
|
||||
state_set(EL_STR("soul.last_refresh_ts"), int_to_str(now_ts));
|
||||
}
|
||||
sleep_ms(tick_ms);
|
||||
el_arena_pop(tick_mark);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user