perf(v2): skip runtime fileHash cache in prod & get timestamp asynchronously #1951
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.
Motivation
showLastUpdateAuthor
/showLastUpdateTime
asynchronously instead of synchronously.Not sure why we did it synchronously previously, but since we are using child_process under the hood to actually do the git call, its better in async
P.S: We also use
execa
instead ofcross-spawn
because https://github.com/sindresorhus/execa has more stars (2.7k vs 600). It also strips the final newline from the output so you don't have to do stdout.trim(), Cleans up spawned processes when the parent process dies and have more descriptive errors.Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
With fixtures of 1,026 docs and several runs
Before -~89s.
After ~~46s
The git call is indeed expensive, disabling
showUpdatedAuthor
andshowUpdatedTime
reduce first cold 'Load' time to only 4s. But well, this is still an optimization