-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby-plugin-mdx): Stop clobbering the same file over and over again #27974
Conversation
How does memory usage look like? We probably keep many strings in memory, what does gatsbyjs.com say? |
No idea. Will have to test this later. Currently have everything wired up for tracing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Danger run resulted in 1 fail and 1 markdown; to find out more, see the checks page. Generated by 🚫 dangerJS |
…again (#27974) (#28874) * perf(gatsby-plugin-mdx): Stop clobbering the same file over and over again * Undo the await part, can be separate PR Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com> (cherry picked from commit 3d100e3) Co-authored-by: Peter van der Zee <209817+pvdz@users.noreply.github.com>
This function (
cacheScope
) takes a bunch of imports and exports, generates a snippet of JS, conditionally runs it through Babel, and writes the resulting snippet out to a file. The filename is a hash based on the resulting data.This means that if
cacheScope
receives the same inputs, it will have the same behavior. Writing the same output to the same file, over and over again. This PR stops that.It uses a global set to use as session cache which I think is safe since these files should not be deleted during a build (not even
develop
).Tested this on
gabe-fs-mdx
at 100k pages.The sourcing step went down from 260s to 200s, roughly a 25% perf win.
(Unfortunately the page query step is still 50 minutes)
This work is roughly based on #25808, which I abandoned after some time (I forgot why). I feel pretty confident about this PR.