Skip to content

module style 4: add cache for module compilation - #345

Merged
prozacchiwawa merged 30 commits into
mainfrom
20260216-freeze-early-cache
Apr 21, 2026
Merged

prozacchiwawa merged 30 commits into
mainfrom
20260216-freeze-early-cache

Conversation

@prozacchiwawa

@prozacchiwawa prozacchiwawa commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Adds a new on-disk cache that can bypass module compilation/optimization and directly rehydrate compiled exports, which affects build correctness if cache keys or fingerprints are wrong. Also changes output file writing behavior (directory creation + error propagation details), impacting artifact generation paths.

Overview
Adds an on-disk cache for module-style compilation outputs. The compiler now fingerprints include inputs, computes a cache key from those fingerprints, and on a cache hit skips codegen/optimization by loading cached .hex exports, reconstructing the module summary/hashes, and re-emitting the expected output and companion *_hash.hex files.

Updates module compilation to populate the cache for each export, introduces IncludeDesc.fingerprint to drive cache invalidation (including a synthetic main fingerprint), and extends tests with new module fixtures plus a regression test that verifies cached artifacts are reused. Includes small refactors/cleanups and dependency lockfile bumps (e.g., cc, zerocopy, serde).

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

@socket-security

socket-security Bot commented Feb 17, 2026 •

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • cargo/cc@1.2.55
  • cargo/zerocopy-derive@0.8.39

View full report

@prozacchiwawa

Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore cargo/zerocopy-derive@0.8.39

@prozacchiwawa prozacchiwawa changed the title 20260216 freeze early cache module style 4: add cache for module compilation Feb 17, 2026
@prozacchiwawa
prozacchiwawa marked this pull request as ready for review February 19, 2026 05:26
@prozacchiwawa

Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore cargo/cc@1.2.55

Comment thread src/compiler/compiler.rs Outdated
Comment thread src/compiler/diskcache.rs Outdated
Comment thread src/compiler/compiler.rs
Comment thread src/compiler/compiler.rs
Comment thread src/tests/compiler/modules.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.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Cache key concatenates fingerprints without length-prefixing causing ambiguity
    • The cache key now prefixes each include fingerprint with its length before hashing, so empty and variable-length fingerprints are encoded unambiguously.

Create PR

Or push these changes by commenting:

@cursor push 415a928f33
Preview (415a928f33)
diff --git a/src/compiler/diskcache.rs b/src/compiler/diskcache.rs
--- a/src/compiler/diskcache.rs
+++ b/src/compiler/diskcache.rs
@@ -7,7 +7,8 @@
 fn cache_key(cf: &CompileForm) -> String {
     let mut include_fingerprints = Vec::new();
     for include in cf.include_forms.iter() {
-        include_fingerprints.append(&mut include.fingerprint.clone());
+        include_fingerprints.extend_from_slice(&(include.fingerprint.len() as u64).to_be_bytes());
+        include_fingerprints.extend_from_slice(&include.fingerprint);
     }
     hex::encode(sha256tree_from_atom(&include_fingerprints))
 }

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread src/compiler/diskcache.rs

@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.

There are 2 total unresolved issues (including 1 from previous review).

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/compiler.rs
Base automatically changed from 20260202-better-test-result to main April 15, 2026 23:04
@prozacchiwawa
prozacchiwawa merged commit b1aee26 into main Apr 21, 2026
35 checks passed
@prozacchiwawa
prozacchiwawa deleted the 20260216-freeze-early-cache branch April 21, 2026 02:34
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