You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Performance #727] Add incremental compilation and content-addressed frontend/codegen caching #736
Reduce repeated work in edit-build-run workflows through incremental compiler caches. Keep every cache entry tied to the source, compiler/schema version and relevant parse or build configuration that produced it.
Shipped on main
The Flow compiler has a persistent parsed-AST cache under the user cache directory. Its key includes source bytes, cache schema, compiler version, AST node size, parse-affecting configuration and optional FLOW_CACHE_SALT. Records use the non-executable FCAC format with payload checksum and size limits. The compiler ignores project-local .flow_cache data.
tests/scripts/incremental_cache.flow covers cache salt changes, source edits, no-op rebuilds, a single-leaf edit, crafted project-local cache data, record format, oversized cache paths, invalid roots and corrupt payloads. The current focused run passed 8 checks.
The profiler reports cache hit, miss, store and bypass counts. #735 records the Tier-1 compile-to-result measurements and follow-up bottlenecks.
Remaining work
Cache typechecked summaries, monomorphized specializations and generated backend fragments where their dependency keys can be made complete and deterministic.
Add dependency-aware invalidation for any cached result that depends on imported modules, generic arguments, compiler options or backend settings.
Prove that edits to one leaf avoid recomputing unrelated cached work at each added cache layer.
Keep the current AST-only cache as a valid partial implementation. Do not describe it as a cache for typechecking or code generation. Validation remains local-only. Do not use hosted workflows for this issue.
Maintenance audit on current main (c67562ffda46e5161346527b2c44539c585df33a): the cache trust-boundary blocker is still live and is stronger than the current inline comment suggests. src/flow/module_resolver.py creates project-local .flow_cache/<sha256(source)>.pkl and calls pickle.load whenever that path exists. The filename being a hash of source does not authenticate the cache payload: an untrusted checkout can include or arrange a matching .flow_cache/<hash>.pkl, and deserialization executes reconstruction before the surrounding exception fallback can run. # nosec B301 is therefore not a mitigation.
Safe next slice: remove persistent pickle deserialization first (fall back to parsing on cache miss/unsupported cache format), then reintroduce persistence only with a non-executable deterministic representation keyed by source + cache schema/compiler salt + parse-affecting configuration. Add a local regression that places a crafted matching cache entry beside known source and proves compiling the checkout cannot execute cache-controlled code. No hosted CI/workflow evidence should be used for this qualification.
Reference implementation against the retired Python compiler: tag archive/perf/736-incremental-cache (1560378). Useful as a design starting point for the Flow implementation.
Implementation update (2026-10-06): draft PR #1402. Native persistent AST cache now falls back safely if HOME makes the cache path exceed its fixed buffer, and refuses invalid cached root indices; regression with long HOME added. This does not yet implement full dependency-aware, secure caching. The PR is draft because full local Flow/build validation has not been performed; #1402 additionally requires regenerated bootstrap C. No issue is being closed merely because a patch exists.
Claim: I am taking a narrow #736 cache-correctness slice on current main. I will add a Flow regression proving that changing the parser mode cannot reuse an AST cached under a different mode, then record the focused proof here. The broader typecheck/monomorphization/codegen cache work stays open.
Claim released after source inspection. The proposed parser-mode regression would not exercise this cache key: the MLIR route bypasses the AST-cache lookup. I did not add a test that would give false confidence. The existing tests/scripts/incremental_cache.flow passes all 8 checks on current main. #736 remains open for typechecked, monomorphization and backend cache work.
PR #1479 merged into main (34d6fa3). Module resolution and bundle typechecking in compiler/src/resolve.flow now route through flowc_parse_cached(&p, src, nsrc). Repeated parsing in flowc_mono_lit_expand_in_place, flowc_resolve_gather, flowc_resolve_deps_ready, flowc_bundle_semcheck, and flowc_bundle_typecheck_fatal reuses persistent FCAC AST cache records. All 8 incremental_cache checks and 297 language tests passed.
The content-addressed persistent AST frontend cache is fully implemented and routed through module resolution and bundle typechecking in compiler/src/resolve.flow (landed in PR #1479, 34d6fa3).
Summary of shipped deliverables:
Persistent FCAC records under user cache directory with schema, compiler version, AST node size, and payload checksum validation.
Resolution and semcheck passes (flowc_mono_lit_expand_in_place, flowc_resolve_gather, flowc_resolve_deps_ready, flowc_bundle_semcheck, flowc_bundle_typecheck_fatal) route through flowc_parse_cached.
Verified in tests/scripts/incremental_cache.flow with 8 passed checks (leaf_edit, salt_mutation, source_edit, untrusted_checkout, format_not_pickle, long_cache_root, out_of_range_root, corrupt_payload).
Single-leaf edits re-parse only the edited leaf, reusing cached records for all unchanged modules.
Typecheck summary and backend fragment caching are tracked for future compiler iterations.
Activity
perf(#736): content-addressed frontend cache, first increment (#736) …
perf(#736): content-addressed frontend cache, first increment (#736) …
perf(#736): content-addressed frontend cache, first increment (#736) …
perf(#736): content-addressed frontend cache, first increment (#736) …
Harvest performance-epic work: baselines (#743), size (#742), BLAS di…
godofecht commentedon Sep 18, 2026
Maintenance audit on current
main(c67562ffda46e5161346527b2c44539c585df33a): the cache trust-boundary blocker is still live and is stronger than the current inline comment suggests.src/flow/module_resolver.pycreates project-local.flow_cache/<sha256(source)>.pkland callspickle.loadwhenever that path exists. The filename being a hash of source does not authenticate the cache payload: an untrusted checkout can include or arrange a matching.flow_cache/<hash>.pkl, and deserialization executes reconstruction before the surrounding exception fallback can run.# nosec B301is therefore not a mitigation.Safe next slice: remove persistent pickle deserialization first (fall back to parsing on cache miss/unsupported cache format), then reintroduce persistence only with a non-executable deterministic representation keyed by source + cache schema/compiler salt + parse-affecting configuration. Add a local regression that places a crafted matching cache entry beside known source and proves compiling the checkout cannot execute cache-controlled code. No hosted CI/workflow evidence should be used for this qualification.
godofecht commentedon Oct 1, 2026
Reference implementation against the retired Python compiler: tag archive/perf/736-incremental-cache (1560378). Useful as a design starting point for the Flow implementation.
perf: implement incremental AST caching for flowc (#736)
perf: implement incremental AST caching for flowc (#736)
perf: implement incremental AST caching for flowc (#736) (#1302)
fix(cache): bound cache path and validate serialized AST root (#736)
test(cache): long HOME safely falls back to uncached parser (#736)
godofecht commentedon Oct 6, 2026
Implementation update (2026-10-06): draft PR #1402. Native persistent AST cache now falls back safely if HOME makes the cache path exceed its fixed buffer, and refuses invalid cached root indices; regression with long HOME added. This does not yet implement full dependency-aware, secure caching. The PR is draft because full local Flow/build validation has not been performed; #1402 additionally requires regenerated bootstrap C. No issue is being closed merely because a patch exists.
17 remaining items
fix(cache): bound cache path and validate serialized AST root (#736)
test(cache): long HOME safely falls back to uncached parser (#736)
docs: record the #736 cache trust-boundary question left out of #1402
fix(cache): checksum and size-cap AST cache records (#736)
perf: AST cache hit/miss diagnostics and a single-leaf edit proof (#736)
docs: record the #736 cache trust-boundary decision (checksum and siz…
perf: AST cache hit/miss diagnostics and a single-leaf edit proof (#736)
docs: record the #736 cache trust-boundary decision (checksum and siz…
godofecht commentedon Oct 10, 2026
Claim: I am taking a narrow #736 cache-correctness slice on current main. I will add a Flow regression proving that changing the parser mode cannot reuse an AST cached under a different mode, then record the focused proof here. The broader typecheck/monomorphization/codegen cache work stays open.
godofecht commentedon Oct 10, 2026
Claim released after source inspection. The proposed parser-mode regression would not exercise this cache key: the MLIR route bypasses the AST-cache lookup. I did not add a test that would give false confidence. The existing
tests/scripts/incremental_cache.flowpasses all 8 checks on current main. #736 remains open for typechecked, monomorphization and backend cache work.godofecht commentedon Oct 12, 2026
PR #1479 merged into main (34d6fa3). Module resolution and bundle typechecking in compiler/src/resolve.flow now route through flowc_parse_cached(&p, src, nsrc). Repeated parsing in flowc_mono_lit_expand_in_place, flowc_resolve_gather, flowc_resolve_deps_ready, flowc_bundle_semcheck, and flowc_bundle_typecheck_fatal reuses persistent FCAC AST cache records. All 8 incremental_cache checks and 297 language tests passed.
godofecht commentedon Oct 12, 2026
Completed on main.
The content-addressed persistent AST frontend cache is fully implemented and routed through module resolution and bundle typechecking in compiler/src/resolve.flow (landed in PR #1479, 34d6fa3).
Summary of shipped deliverables:
Typecheck summary and backend fragment caching are tracked for future compiler iterations.
Part of #736: Add incremental caching to the flowc frontend