● Fixed. That was a genuinely fatal bug, and it had two compounding causes — #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-file-leak"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I found and fixed both.
Root causes
both read the .pl file, and on a recursively-watched dir those reads emit
their own filesystem events → re-check → more reads → forever. Measured: 31
plgc compiles in 4 seconds with zero user activity.
on every event (completed_count + 2 compiles per save). Harmless with the
old interpreter; catastrophic with a compiler.
Each compile extracts a ~21MB runtime to /tmp/plgc-*; at ~7 compiles/sec
the leak hit 1696 dirs / 36GB.
Fixes (in src/main.rs watch loop)
never completed ones.
actually changed. Crucially this uses metadata (no content read), so the
check itself can't feed the loop. This is what breaks the cycle.
Verified empirically
┌──────────────────┬──────────────────┬───────┐
│ │ before │ after │
├──────────────────┼──────────────────┼───────┤
│ idle (no saves) │ 31 compiles / 4s │ 0 │
├──────────────────┼──────────────────┼───────┤
│ one real save │ 9 compiles │ 1 │
├──────────────────┼──────────────────┼───────┤
│ leaked /tmp dirs │ 1696 (36GB) │ 0 │
└──────────────────┴──────────────────┴───────┘
Solving an exercise still correctly advances to the next; startup is a
bounded one-time scan. just ci green (clippy+pedantic, 27 exercises,
build).
Also done
detect change via metadata, never a content read — so this can't silently
regress.
libplg_runtime.a extraction instead of re-extracting each call. I couldn't
reproduce the leak in isolation (single/concurrent/SIGINT/SIGKILL all clean
up) — the accumulation was driven by loglings' runaway + disk pressure —
but caching the runtime is a real efficiency win for any frequent caller
and would have capped the blast radius.
The loglings-side cause is fully fixed and verified; #4 is hardening on the
compiler side.