Repository navigation
fix(fasl): replay a nested (load) once on a warm hit (#92; stacked on #89) - #94
Merged
Merged
Conversation
When a recorded load ran another load from inside one of its chunks (a top-level (load ...) form, or a function that loads), splice_into_outer also copied the inner load's records into the outer fasl. On a hit the outer chunk re-ran the load and the spliced copy replayed it again, so the inner file's output printed twice on every warm run. Splice only when the outer span is not in a chunk, which is the case the splice exists for (a load whose effects no outer record reproduces). Deps are still propagated either way. Fixes #92 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fasl written before the previous commit already holds the spliced copy of an in-chunk nested load, and the cache key does not cover boot.lua, so an upgraded build still hit it and printed the nested output twice. A new header makes fasl_parse reject those files: they are recompiled once, then cached correctly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sted-load # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #92
Stacked on #89 (
capcov/fix-86-87-home-dir-cache@ 7ad7ae4). The fix doesn't depend on #89: the boot.lua and test changes cherry-pick ontomaincleanly. The only conflict is a textual one in CHANGELOG.md, where this entry sits next to #89's. Only the f-modelcheck acceptance run needs #89, because that driver does(cd ...)and then loads relative paths. If #89's branch is merged and deleted, GitHub retargets this PR tomain.Root cause
splice_into_outer(boot.lua,install_fasl) copies a nested load's fasl records into the enclosing recording. The splice exists so that an outer stream has no hole for a nested load. It also ran when the nested load happened inside one of the outer file's chunks: a top-level(load ...)form, or a function that callsload. That load is already in the outer stream as the chunk that calls it. On a warm hit, replaying that chunk ran the nested load again, from its own fasl, and the spliced copy replayed it a second time. Every nested file's output doubled.Fix
in_chunk.depspropagation and splicing for loads made outside a chunk are unchanged.FASL_FORMATtoSHENFASL7. The fasl key does not cover boot.lua, so caches written by older builds already contain the duplicate. Without the bump, an upgraded build still hit them and printed 36 MC lines. Now they miss once and are rewritten.test/cli_spec.luacovers two cases: a top-level nested load, and a load from a function. Each is checked cold, warm (asserted to be a fasl hit), warm again, and withSHEN_FASL=off. All runs must printBEGIN LIB LIB END. At 7ad7ae4 the warm checks fail (4 fails); at head they pass.Evidence (LuaJIT 2.1.1785763465, macOS arm64, private TMPDIR/XDG_CACHE_HOME/SHEN_KERNEL_CACHE/SHEN_FASL_DIR)
Issue repro (
--hush-load, cold → warm → warm, thenSHEN_FASL=off):capcov f-modelcheck, one fasl dir, run 0 cold then runs 1–3 warm (22 fasl hits, 0 misses):
Suites:
🤖 Generated with Claude Code