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
Config caching #5292
Config caching #5292
Conversation
This avoids repeated `fs.readFileSync` calls.
Like configs, ignore files are only read once now.
@akx, thanks for your PR! By analyzing the history of the files in this pull request, we identified @hzoo, @jamestalmage and @SimenB to be potential reviewers. |
Good catch! I actually also noticed that while tracing the Node process. Babel looks at all directories to find a I think we could cache this information as well. I don't expect much a perfomance boost since no JSON parsing is involved. Should we and how cache the result of a |
@xtuc Cheers :) Mm, you mean caching which |
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.
lgtm
@akx no sorry, I meant that we could store directories where there is no |
I missed this PR entirely :P I'd be curious to see what #5608 does to these stats, since it |
So yeah, I guess this was superseded by #5608. Closing... |
I've been debugging some build slowness issues with Node's
--trace-sync-io
flag and I noticedbuild-config-chain.js
ends up re-re-re-reading the same configuration file(s) over and over again, and as it's using sync IO, the Node.js event loop gets blocked.This PR adds filename-keyed in-memory caching for configuration (
package.json
/.babelrc
) and ignore (.babelignore
) files.This should be backwards-compatible, aside from processes which modify or create Babel configuration or ignore files during the lifetime of the builder process. I think that's a corner case not worth worrying too much about.
Performance impact
For the build I'm debugging, this seems to remove some 1,500 sync call warnings:
Most of the remaining sync call warnings are from
babel-loader
, for which there's a similar PR (babel/babel-loader#375).To be somewhat more exact using summarize-sync-io, Babel used to do
and with this patch, it does
for this particular build. :)
As for memory usage impact, I expect it to be negligible -- adding eslintignore files to the cache has to be peanuts all considered.