Skip to content

module style 4.5: introduce function cache to speed up some optimizations - #369

Merged
aqk merged 43 commits into
mainfrom
20260302-introduce-function-cache
Apr 23, 2026
Merged

aqk merged 43 commits into
mainfrom
20260302-introduce-function-cache

Conversation

@prozacchiwawa

@prozacchiwawa prozacchiwawa commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Introduces a new caching path in codegen that can change emitted helper bodies when cache keys collide or are computed incorrectly, and it touches core compilation/optimization flow. Risk is mitigated by being opt-in (requires funcache + dependency graph) and covered by new targeted tests.

Overview
Adds an optional per-function codegen cache (Funcache) to reuse previously generated non-inline defun outputs during optimization runs when the helper’s effective dependencies (used constants/inlines + relevant env shape) haven’t changed.

codegen/codegen_ now accept an optional FunctionDependencyGraph; when provided and funcache is enabled on the compile context, helpers can be served from cache via a sha256tree-based key computed from the helper form plus depended-on forms (with unused env entries nil’d). Adds new tests for module disk-cache key stability/try_from_cache behavior and for funcache correctness, plus a small coverage-script doc update and .gitignore additions.

Reviewed by Cursor Bugbot for commit 060450b. Bugbot is set up for automated code reviews on this repo. Configure here.

@prozacchiwawa prozacchiwawa changed the title modules 4.5, 20260302 introduce function cache module style 4.5: 20260302 introduce function cache Mar 3, 2026
@prozacchiwawa prozacchiwawa changed the title module style 4.5: 20260302 introduce function cache module style 4.5: introduce function cache to speed up some optimizations Mar 3, 2026
@prozacchiwawa
prozacchiwawa marked this pull request as ready for review March 3, 2026 10:02
Comment thread src/compiler/codegen.rs Outdated
Comment thread src/compiler/codegen.rs
Comment thread src/compiler/codegen.rs Outdated
Comment thread src/compiler/codegen.rs
…the provided compileform. This eliminates the possibility of the context containing a stale dependency graph.
Comment thread src/compiler/optimize/deinline.rs
Comment thread src/compiler/codegen.rs
… well. not really necessary since this was checked when the first generation happened, but its ok
Comment thread src/tests/compiler/resolve.rs Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread src/compiler/optimize/deinline.rs
Base automatically changed from 20260216-freeze-early-cache to main April 21, 2026 02:34
@aqk
aqk enabled auto-merge April 23, 2026 04:26
@aqk
aqk merged commit c6af0bf into main Apr 23, 2026
35 checks passed
@aqk
aqk deleted the 20260302-introduce-function-cache branch April 23, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants