gc diagnostics: per-tier heap pressure surfaced in repl tabbar

Step 1 of the GC effort. Each tier loader now exposes heapStats():
  - asm-wasm — lumbda_heap_used / lumbda_heap_total wat exports
  - c-wasm   — emscripten linear memory size (no free path right now,
               so used = total; documented in the loader)
  - python   — pyodide module linear memory size; CPython GC cycles
               this naturally

Worker handles a "heap" message kind that round-trips the active tab's
loaded tiers; repl tabbar shows a compact "py 12M · c 32M · asm 4M"
strip next to the buttons. Polls every 2s.

Doesn't solve the leak — just makes pressure visible so the user knows
when to use "reboot tier". Real GC (Cheney over the WAT bump allocator,
Boehm-em or custom mark-sweep for c-wasm) coming next.
This commit is contained in:
russell@unturf.com 2026-06-14 17:32:48 -04:00
parent 88e16c0ce2
commit ff2ef382c7
No known key found for this signature in database
31 changed files with 426 additions and 28 deletions

View file

@ -56,6 +56,13 @@ def _lumbda_eval(src):
pyodide.globals.set("_src_in", src);
return await pyodide.runPythonAsync("_lumbda_eval(_src_in)");
},
heapStats() {
// Pyodide's runtime memory is the Emscripten linear memory.
// CPython's GC reclaims behind the scenes, so this number
// rises and falls naturally as objects die.
const total = pyodide._module.HEAPU8.byteLength;
return { used: total, total };
},
};
}