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

perf(v2): skip runtime fileHash cache in prod & get timestamp asynchronously #1951

Merged
merged 3 commits into from
Nov 8, 2019

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Nov 8, 2019

Motivation

  • Skip fileHash caching on production calculation to improve build performance. The runtime cache is only useful in development.
  • Obtain git timestamp for 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 of cross-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.

before 89s

After ~~46s
after 46s

The git call is indeed expensive, disabling showUpdatedAuthor and showUpdatedTime reduce first cold 'Load' time to only 4s. But well, this is still an optimization

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 8, 2019
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit 57f49ff

https://deploy-preview-1951--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 57f49ff

https://deploy-preview-1951--docusaurus-preview.netlify.com

@endiliey endiliey added the pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient. label Nov 8, 2019
@endiliey endiliey merged commit 639d8d3 into master Nov 8, 2019
@endiliey endiliey deleted the endi/generatehash branch November 8, 2019 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants