Repository navigation
perf: schema-salted non-executable parse cache (#736) - #1345
Merged
Merged
Conversation
Key parsed-declaration records by cache schema, compiler version, node size, parse-affecting config, and FLOW_CACHE_SALT. Persist integer FCAC records under the user cache so an untrusted checkout cannot execute crafted project-local cache data. Co-authored-by: Abhishek Shivakumar <[email protected]>
Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
marked this pull request as ready for review
October 5, 2026 02:09
This was referenced Oct 5, 2026
Keep main's FLOWC_PROF_CACHE span around the cache probe. Regenerate bootstrap C and Linux x86-64 flowc_stage_a ELF.
Resolve bootstrap binary by taking main then regenerating.
Regenerated bootstrap on Mac (fixed point gen2) and rebuilt the checked-in ELF on Linux for CI self-host.
Record 28 corpus programs whose MLIR changed after the main merge.
Bootstrap binary and corpus digests taken from main; will regen and re-record.
godofecht
added a commit
that referenced
this pull request
Oct 6, 2026
godofecht
added a commit
that referenced
this pull request
Oct 6, 2026
Brings in #1345, which salts the parse-cache key with a schema, node size and parse-affecting config and re-records the MLIR corpus goldens it affects. That is what the previous merge could not fix: before #1345 the parse cache was not schema validated, so a program's emitted MLIR depended on which files the corpus run had already parsed, and this branch's new fixtures changed that state on CI. With the cache now transparent (measured: identical MLIR with and without FLOW_CACHE_SALT), main's flowc and the merged flowc emit byte-identical MLIR for tests/lang/test_typecheck_overload_integration.flow, so the merged compiler matches main's recorded digest 81533a1e. Conflict: compiler/bootstrap/flowc_stage_a (binary) was taken from main. The generated .c was reset to main's copy because it auto-merged, then regenerated from the merged compiler/src with bootstrap_from_c.sh --regen (fixed point at gen2); --verify reports it as self-reproducing. Generated with Codebuff (https://codebuff.com) Co-Authored-By: Codebuff <[email protected]>
This was referenced Oct 7, 2026
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
Records gain a u64 payload checksum after the header (schema 2) and are neither written nor read above 4194304 nodes. A record whose payload does not match, or that has trailing bytes, is a miss and is re-parsed. The directory trust model from #1345 is unchanged, per the resolved question in docs/project/Questions.md.
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
Records gain a u64 payload checksum after the header (schema 2) and are neither written nor read above 4194304 nodes. A record whose payload does not match, or that has trailing bytes, is a miss and is re-parsed. The directory trust model from #1345 is unchanged, per the resolved question in docs/project/Questions.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.
Intent
Linked issue: #736 (first slice only).
The parsed-declaration cache that landed in #1302 hashed source plus a version mix and wrote raw AST words under
~/.cache/flow/ast. This slice closes the two blockers named on the issue:AstNodesize, parse-affecting config (bundle expand-all stages and MLIR parse mode), optionalFLOW_CACHE_SALT, and the source bytes. A salt mutation test proves a new key is allocated when the salt changes and the source does not.FCACinteger record (magic, schema, node size, length, root, thenAstNodewords) only under$XDG_CACHE_HOME/flow/astor$HOME/.cache/flow/ast. A checkout.flow_cache/is never opened. Load is a memcpy of integers; pickle is not used.This is not typecheck, monomorphize, or codegen caching, and it is not a full import-dependency graph. Those remain open on #736.
Overlap check
Open PRs #1332 #1331 #1330 #1329 #1328 #1326 #1325 #1268 #1267 #1265 are unrelated (MLIR flags and benchmarks). #1302 already merged a first AST cache; this PR hardens that cache rather than starting a second one.
Evidence
Baseline before this change: on
9a278876the cache key omitted parse-affecting config and an explicit schema constant; the on-disk header was a bare736magic; there was no salt-only mutation test and no untrusted-checkout proof.Targeted proof:
./flow tool tests/scripts/incremental_cache.flowsalt_mutation— same source,FLOW_CACHE_SALT=frontend-v1thenfrontend-v2; a new.astfile appears only after the salt change.source_edit— edited helper return value is observed.untrusted_checkout— protocol-0 pickle under project.flow_cache/that wouldtoucha sentinel if loaded does not run.format_not_pickle— user-cache records begin withFCAC.Why that proof would detect the old failure: a key that ignored salt would keep a single record across the salt change; a pickle loader would create the sentinel.
Repository gate(s) run:
./flow tool tests/scripts/incremental_cache.flow— 4 passedenv -u FLOWC_IN -u FLOWC_OUT "$(./flow tool compiler/scripts/flowc_host.flow)"—flowc: PASS./compiler/scripts/bootstrap_from_c.sh --regen— fixed point at gen2./compiler/scripts/bootstrap_from_c.sh --verify—PASS bootstrap C matches compiler/srcGenerated/bootstrap state:
compiler/bootstrap/flowc_stage_a.cregenerated in a separate commit after thecompiler/src/edits.Risk
Internal compiler cache only. Existing
~/.cache/flow/astrecords with the old header miss and reparse. Cold builds are unchanged when the cache directory cannot be created.docs/project/Questions.mdupdated if this needs a language-design decision.Compatibility
docs/project/CHANGELOG.md.Agent handoff
Remaining #736 gaps, still on the issue: dependency-aware invalidation, typecheck/monomorphize/codegen caches, cache hit/miss diagnostics, stale-executable prevention.