Skip to content

fix(probe): exclude volatile env pseudo-vars from probe key (#201) - #205

Closed
emmanuelm41 wants to merge 1 commit into
mainfrom
fix/windows-probe-env-key
Closed

fix(probe): exclude volatile env pseudo-vars from probe key (#201)#205
emmanuelm41 wants to merge 1 commit into
mainfrom
fix/windows-probe-env-key

Conversation

@emmanuelm41

Copy link
Copy Markdown
Member

Closes #201.

Problem

On the Windows e2e arm (#82) the compiler-probe memo missed on the warm build, re-running the probe — probe_runs = 1 where c-hello / c-depinfo assert max_probe_runs = 0:

{"name": "max_probe_runs", "expected": "<= 0", "actual": "1", "passed": false}

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 in env_fingerprint(), which hashes the entire process environment. On Windows std::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 status

These shift between the cold and warm make invocations, so the probe key differed across builds and the warm load() looked up a {key}.json that 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 pure fingerprint_env core (+ is_volatile_env_name predicate) 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, and cargo test -p kache (626 passed) all green locally.

Validation: the Windows e2e arm (non-blocking, self-hosted kunobi-windows runner) on this PR's CI run should now show c-hello / c-depinfo warm with probe_runs = 0.

@emmanuelm41
emmanuelm41 force-pushed the fix/windows-probe-env-key branch from 3e96c75 to 5fbc83f Compare June 1, 2026 23:22
@emmanuelm41
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

Copy link
Copy Markdown
Member Author

Superseded by #209, which consolidates the remaining Windows e2e fixes (this PR's changes are included there as a dedicated commit) so the whole arm can be driven to green in one CI run. Closing in favor of #209.

@emmanuelm41 emmanuelm41 closed this Jun 2, 2026
@emmanuelm41
emmanuelm41 deleted the fix/windows-probe-env-key branch June 2, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: cc compiler-probe not memoized across builds (warm re-runs the probe)

1 participant