fix(probe): exclude volatile env pseudo-vars from probe key (#201) - #205
Closed
emmanuelm41 wants to merge 1 commit into
Closed
fix(probe): exclude volatile env pseudo-vars from probe key (#201)#205emmanuelm41 wants to merge 1 commit into
emmanuelm41 wants to merge 1 commit into
Conversation
emmanuelm41
force-pushed
the
fix/windows-probe-env-key
branch
from
June 1, 2026 23:22
3e96c75 to
5fbc83f
Compare
emmanuelm41
marked this pull request as draft
June 1, 2026 23:26
The compiler-probe memo missed on the warm build on Windows, so the probe re-ran (`probe_runs = 1` where `c-hello`/`c-depinfo` assert `max_probe_runs = 0`). Everything else on that phase passed — the compile was a `local_hit`, the diff byte-identical — because the *main* cache key hashes only a curated env subset (RUSTFLAGS, CARGO_CFG_*), which is stable. The probe key, by contrast, mixes in `env_fingerprint()`, which hashes the *entire* environment. On Windows `std::env::vars()` surfaces cmd.exe's hidden `=`-prefixed pseudo-variables — the per-drive working directory (`=C:`, `=D:`) and the previous child's `=ExitCode`. Those shift between the cold and warm `make` invocations, so the probe key differed across builds and the warm `load()` looked up a record cold never wrote → miss → re-probe. Unix variable names can't contain `=`, so the bug is Windows-only. Filter `=`-prefixed names out of the env fingerprint. Refactored into a pure `fingerprint_env` core so the filtering is unit-testable without mutating the process environment; added regression tests. No-op on Unix.
emmanuelm41
force-pushed
the
fix/windows-probe-env-key
branch
from
June 2, 2026 11:36
5fbc83f to
9b18a51
Compare
Member
Author
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.
Closes #201.
Problem
On the Windows e2e arm (#82) the compiler-probe memo missed on the warm build, re-running the probe —
probe_runs = 1wherec-hello/c-depinfoassertmax_probe_runs = 0:Everything else on that phase passed (compile
local_hit,compiler_runs: 0, diff byte-identical, verify ok) — only the probe memo failed to hit. Not a #196 regression.Root cause
The probe key (
src/probe/cache.rs::probe_key) mixes inenv_fingerprint(), which hashes the entire process environment. On Windowsstd::env::vars()surfaces cmd.exe's hidden=-prefixed pseudo-variables:=C:,=D:, … — the per-drive current working directory=ExitCode— the previous child process's exit statusThese shift between the cold and warm
makeinvocations, so the probe key differed across builds and the warmload()looked up a{key}.jsonthat cold never wrote → miss → re-probe.This is Windows-only because Unix variable names cannot contain
=. It breaks only the probe memo (not the compile cache) because the main cache key (cache_key.rs) hashes only a curated env subset (RUSTFLAGS,CARGO_ENCODED_RUSTFLAGS,CARGO_CFG_*) — which stays stable — exactly matching the observed "compile hits, probe re-runs".Fix
Filter
=-prefixed names out of the env fingerprint. Refactored the hashing into a purefingerprint_envcore (+is_volatile_env_namepredicate) so the filtering is unit-testable without mutating the real environment. No-op on Unix.Tests
Added 3 regression tests (
fingerprint_env_ignores_windows_hidden_pseudo_vars,fingerprint_env_still_reflects_real_vars,is_volatile_env_name_flags_only_equals_prefixed).cargo fmt,cargo clippy --all-targets, andcargo test -p kache(626 passed) all green locally.Validation: the Windows e2e arm (non-blocking, self-hosted
kunobi-windowsrunner) on this PR's CI run should now showc-hello/c-depinfowarm withprobe_runs = 0.