Skip to content

Conversation

chengcyber
Copy link
Contributor

@chengcyber chengcyber commented Sep 26, 2022

Summary

This PR makes Rush.js restores the duration of the same operation without cache hit and log durationInSecondsWithoutCache in operationResult

Details

  1. When operation doesn't hit cache, Rush.js creates a .rush/temp/operation/<identifier>/state.json which contains durationInSecondsWithoutCache.
  2. Set the state.json in Step 1 as an additional output file when create project build cache tarball.
  3. When operation hit cache, read the restored state.json and set durationInSecondsWithoutCache as one of the property of operationResult

How it was tested

  • Tested it with local build cache in rushstack repo
  • Tested it with cloud build cache in private repo

Test with local build cache in rushstack repo steps:

  1. Enable telemetry by setting up "telemetryEnabled": true in rush.json
  2. Run rm -rf common/temp/build-cache
  3. Run node rush-lib/lib/start.js build -v --to tree-pattern
    a. libraries/tree-pattern/.rush/temp/operation/_phase_build/state.json created
    b. libraries/tree-pattern/.rush/temp/rushstack+tree-pattern-_phase_build-<identifier>.log shows .rush/temp/operation/_phase_build/state.json is included when creating build archive.
  4. Remove the state.json by running rm rf libraries/tree-pattern/.rush/temp/operation/_phase_build/state.json
  5. Run node rush-lib/lib/start.js build -v --to tree-pattern the second time
    a. libraries/tree-pattern/.rush/temp/operation/_phase_build/state.json restored
    b. common/temp/telemetry/<...>.json records nonCachedDurationMs in operationResult of tree-pattern

@chengcyber chengcyber force-pushed the feat-operation-metadata branch from 6e23717 to 5798706 Compare September 27, 2022 10:16
@chengcyber
Copy link
Contributor Author

Thanks @iclanton and @dmichon-msft for reviewing this.

Batch of code changes according to your suggestions 🤞:

  • renamed the property to nonCachedDurationMs
  • always specifying nonCachedDurationMs in operationResult
  • made ProjectBuildCache#_additionalProjectOutputFiles readonly
  • promoted operationStateFile and stopwatch to IOperationRunnerContext

Could you take another look?

@chengcyber chengcyber requested review from iclanton and dmichon-msft and removed request for iclanton and dmichon-msft September 27, 2022 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants