Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rush] restore the duration of the same operation without cache hit as telemetry data #3649

Merged
merged 7 commits into from
Sep 29, 2022

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
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
common/reviews/api/rush-lib.api.md Outdated Show resolved Hide resolved
@iclanton iclanton merged commit fe7ae5f into microsoft:main Sep 29, 2022
Bug Triage automation moved this from In Progress to Closed Sep 29, 2022
@chengcyber chengcyber deleted the feat-operation-metadata branch September 29, 2022 06:52
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
Bug Triage
  
Closed
Development

Successfully merging this pull request may close these issues.

None yet

3 participants