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): improve dev build time by not overwriting file if possible #2089

Merged
merged 3 commits into from Dec 6, 2019

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Dec 5, 2019

Motivation

Cache-loader compares with mtime

And currently, whenever we run new "docusaurus start", we always overwrite a lot of the generated files for the first time, invalidating cache. The next reload is fine, because we have runtime content hash cache.

We can do better by checking If file already exist but its not in runtime cache hash yet, then we try to calculate the content hash and then compare. This is to avoid unnecessary overwrite and we can reuse old file. Thus, cache-loader wont invalidate.

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

Before ~7s
image

My next dev server (second run) went down to ~5s
image

This is minor improvement, but as more metadata is written, this is gonna improve a lot

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@endiliey endiliey added the pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient. label Dec 5, 2019
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 5, 2019
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Dec 5, 2019

Deploy preview for docusaurus-2 ready!

Built with commit 2574e11

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

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Dec 5, 2019

Deploy preview for docusaurus-preview ready!

Built with commit 2574e11

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

@endiliey endiliey requested a review from wgao19 as a code owner December 6, 2019 05:12
@endiliey endiliey changed the title perf(v2): improve sequential build time by not overwriting file if po… perf(v2): improve dev build time by not overwriting file if possible Dec 6, 2019
@endiliey endiliey merged commit 32c9d07 into master Dec 6, 2019
@endiliey endiliey deleted the endi/avoid-overwrite branch December 6, 2019 05:17
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.

None yet

4 participants