Skip to content

[rush] Add --debug-build-cache-ids flag#5173

Merged
dmichon-msft merged 5 commits intomicrosoft:mainfrom
dmichon-msft:build-cache-reconfigure
Mar 27, 2025
Merged

[rush] Add --debug-build-cache-ids flag#5173
dmichon-msft merged 5 commits intomicrosoft:mainfrom
dmichon-msft:build-cache-reconfigure

Conversation

@dmichon-msft
Copy link
Copy Markdown
Contributor

@dmichon-msft dmichon-msft commented Mar 27, 2025

Summary

Adds a new flag --debug-build-cache-ids to phased commands to help diagnose unexpected build cache misses.

Details

Reworked the internals of cache id computation so that the build cache version and salt are applied only at the very end when converting the hash to a cache entry id.
Moved operation state hash computation to occur between createOperations and beforeExecuteOperations to ensure that the hashes are computed based on the established operation graph, and that no mutation of the runtime graph has had a chance to occur.
Added getStateHash() and getStateHashComponents() methods to IOperationExecutionResult so that plugins may leverage that information for debugging. Computation of final build cache ids from the state hash is accessible via the BuildCacheConfiguration object.

Also updates the sort order of the results object so that operations are in lexicographical order by name. This impacts the default result summary and makes it more readable.

How it was tested

Example output:
image

@dmichon-msft ➜ /workspaces/rushstack-2 (build-cache-reconfigure) $ node ./apps/rush/lib/start-dev.js --quiet build --debug-build-cache-ids --to node-core-library
Analyzing repo state... DONE (0.09 seconds)

Executing a maximum of 16 simultaneous processes...
===== Begin Hash Computation =====
--- @rushstack/eslint-config (build) ---
|@rushstack/eslint-patch (build)=4fe3e28c93a14e95853c726f1db1aab21b7bf7bb
|@rushstack/eslint-plugin (build)=2ca569d2e5c986fa5db8beb0e8a0045d6c9cbb73
|@rushstack/eslint-plugin-packlets (build)=935ccf6d8ee5f1b7af39aa2ccf0fefbe2390c21d
|@rushstack/eslint-plugin-security (build)=d98088cef5d6915c85700a6f1697f173d0e20006
|local=1bd778b70b9fcb0442d931ebc2d06edc8cd9d5fe
|config=
Result: 602113874f9db3a27da07342f291700d00bb6b76

--- @rushstack/eslint-patch (build) ---
|local=03d56efebe4ae19f3f6101b575eba1fa0ba48d57
|config=heft run --only build -- --clean 
Result: 4fe3e28c93a14e95853c726f1db1aab21b7bf7bb

--- @rushstack/eslint-plugin (build) ---
|@rushstack/tree-pattern (build)=86dc2c0369ee77d62a54d24956f783a300f58d73
|local=7c38e4f8827366ee1a3c6f586985720dc7f1e9d3
|config=heft run --only build -- --clean 
Result: 2ca569d2e5c986fa5db8beb0e8a0045d6c9cbb73

--- @rushstack/eslint-plugin-packlets (build) ---
|@rushstack/tree-pattern (build)=86dc2c0369ee77d62a54d24956f783a300f58d73
|local=b3890b129baf2f029fc72b54475b31032cf92bc9
|config=heft run --only build -- --clean 
Result: 935ccf6d8ee5f1b7af39aa2ccf0fefbe2390c21d

--- @rushstack/eslint-plugin-security (build) ---
|@rushstack/tree-pattern (build)=86dc2c0369ee77d62a54d24956f783a300f58d73
|local=3aab63ce13f45b410f39fbc4a1e909177ba433d9
|config=heft run --only build -- --clean 
Result: d98088cef5d6915c85700a6f1697f173d0e20006

--- @rushstack/node-core-library (build) ---
|local-eslint-config (build)=144ae5cbbb2186af50c36cf91ddd9fd4b7bbdc6e
|local=76571393340aff7f2bbb465970dae0437d0a60e6
|config=heft run --only build -- --clean 
Result: 14b57b103b4b9a27fa2edebe43378a055ccbb7f2

--- @rushstack/tree-pattern (build) ---
|local=fe67f87960b0278e23b67e768ea7e1d05ddc64c1
|config=heft run --only build -- --clean 
Result: 86dc2c0369ee77d62a54d24956f783a300f58d73

--- local-eslint-config (build) ---
|@rushstack/eslint-config (build)=602113874f9db3a27da07342f291700d00bb6b76
|@rushstack/eslint-patch (build)=4fe3e28c93a14e95853c726f1db1aab21b7bf7bb
|local=b561c574a9f4f169d1da814fcc92657e044e3062
|config=
Result: 144ae5cbbb2186af50c36cf91ddd9fd4b7bbdc6e

===== End Hash Computation =====

Impacted documentation

The documentation of the operation execution results.

Comment thread common/changes/@microsoft/rush/build-cache-reconfigure_2025-03-27-00-38.json Outdated
Comment thread libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts
Comment thread libraries/rush-lib/src/logic/operations/DebugHashesPlugin.ts Outdated
Comment thread libraries/rush-lib/src/api/BuildCacheConfiguration.ts
@dmichon-msft dmichon-msft merged commit 7e5d753 into microsoft:main Mar 27, 2025
5 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Mar 27, 2025
@dmichon-msft dmichon-msft deleted the build-cache-reconfigure branch March 27, 2025 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants