fix(cache): key the object cache on all codegen-affecting env vars (#6394)#6526
Merged
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe object-cache key now incorporates additional compile-time ChangesCodegen cache key invalidation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…6394) The object cache keyed on a curated but incomplete set of codegen env vars. ~16 PERRY_* vars that perry-codegen reads at compile time and that change the emitted .o — typed-feedback site emission, IC and method-dispatch outlining, inline new/ctor, string-init chunking, per-unit -O0/-Os selection, entry-symbol rename, codegen-unit partitioning, volatile-setjmp promotion, and loop GC-poll emission — were absent from the key. Setting any of them against a warm cache silently reused an object built without it: the switch appears to do nothing, and any A/B or bisection built on it is vacuous. Add them to compute_object_cache_key_with_env. Deliberately excluded: runtime-global loads (@PERRY_CLASS_FIELD_INLINE_GUARD_DISABLED / @PERRY_TA_VIEW_GUARD / @PERRY_TA_KIND_CACHE — codegen emits them identically regardless of the compile-time env), diagnostics-only vars, the final-link PERRY_LD, and vars already captured via the resolved target triple (PERRY_WATCHOS_ARM64_32) or the HIR fingerprint (PERRY_GLOBAL_SCRIPT_THIS, PERRY_EVAL_CSP, PERRY_ALLOW_UNIMPLEMENTED). Extends key_changes_with_codegen_env_vars to assert every newly-keyed var (unset vs set vs different value) yields a distinct key. Closes #6394
proggeramlug
force-pushed
the
fix/object-cache-key-codegen-env-vars
branch
from
July 17, 2026 14:24
de8a087 to
20b143e
Compare
proggeramlug
pushed a commit
that referenced
this pull request
Jul 17, 2026
Version + CHANGELOG for the three fixes that green the repo-wide lint job: - #6528 (v0.5.1261): version-invariant Cargo.toml fingerprint in the public-baseline freshness gate. - #6531 (v0.5.1262): split widget_decl.rs under the 2000-line file-size cap. - #6394/#6526 (v0.5.1263): key the object cache on all codegen-affecting env vars. Bumps [workspace.package] 0.5.1260 -> 0.5.1263. The version bump no longer invalidates the benchmark freshness gate (fixed by #6528).
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.
Problem
The object cache (
node_modules/.cache/perry) keys on source + compiler identity + a curated set of codegen-affecting environment variables — but that set was incomplete. Nine vars were keyed (PERRY_WRITE_BARRIERS,PERRY_SHADOW_STACK,PERRY_TARGET_CPU, …), while ~16 otherPERRY_*vars thatperry-codegenreads at compile time — and that change the emitted.o— were not. Setting any of those against a warm cache silently reused an object built without it: the switch appears to do nothing, and any A/B or bisection built on it is vacuous.(Contrary to the issue title,
PERRY_WRITE_BARRIERSitself is already keyed — the env block exists. This PR closes the remaining gap so that no codegen env var can silently no-op with a warm cache.)Fix
Add the missing compile-time codegen env vars to
compute_object_cache_key_with_env(
crates/perry/src/commands/compile/object_cache.rs):PERRY_TYPED_FEEDBACK,PERRY_TYPED_FEEDBACK_TRACE,PERRY_FULL_OUTLINE_IC,PERRY_FULL_OUTLINE_IC_MIN_FUNCS,PERRY_OUTLINE_METHOD_DISPATCH,PERRY_INLINE_NEW,PERRY_INLINE_CTOR,PERRY_STRING_INIT_CHUNK_SIZE,PERRY_LL_O0_THRESHOLD_BYTES,PERRY_LL_SIZE_OPT,PERRY_LL_SIZE_OPT_MAX_FN_BYTES,PERRY_ENTRY_SYMBOL,PERRY_CODEGEN_UNITS,PERRY_CODEGEN_UNIT_SIZE,PERRY_SETJMP_VOLATILE,PERRY_GC_MOVING_LOOP_POLLS.Each is a
std::env::varread inperry-codegenthat changes emitted IR or the.ll→.ocompile decision (typed-feedback site emission, IC inline/outline, method-dispatchoutlining, inline
new/ctor, string-init chunking, per-unit-O0/-Osselection, entry-symbolrename, codegen-unit partitioning, volatile-setjmp promotion, and loop GC-poll emission).
Deliberately excluded
PERRY_CLASS_FIELD_INLINE_GUARD_DISABLED,PERRY_TA_VIEW_GUARD,PERRY_TA_KIND_CACHE— codegen emits loads of@PERRY_*globalsresolved at run time, so the emitted bytes are identical regardless of the compile-time
environment.
PERRY_LLVM_KEEP_IR,PERRY_SAVE_LL,PERRY_NATIVE_REPS*,PERRY_NO_CLANG_PROBE..o:PERRY_LD.PERRY_WATCHOS_ARM64_32(folds into the resolved targettriple, already hashed as
tgt);PERRY_GLOBAL_SCRIPT_THIS/PERRY_EVAL_CSP/PERRY_ALLOW_UNIMPLEMENTED(affect AST→HIR lowering, captured by thehirfingerprint).Over-inclusion only costs an unnecessary cache miss when a rarely-set var is present;
under-inclusion is the silent-wrong-result bug — so the classification errs toward inclusion
for anything that changes emitted bytes.
The auto-optimize archive cache (
target/perry-auto-*, keyed byauto_optimized_cache_key) is a separate mechanism that keys the Rust build of theruntime/stdlib static archives, not the per-module TS
.o; it does not share this blind spotand is out of scope.
Test
Extends
key_changes_with_codegen_env_varsto assert every newly-keyed var (unset vs set vs adifferent value) produces a distinct key, via the existing
compute_object_cache_key_with_envseam (no process-environment mutation).
Closes #6394
Summary by CodeRabbit