-
Notifications
You must be signed in to change notification settings - Fork 71
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
Rollup config hashing for cache is very slow when rebuilding in watch mode #443
Comments
can we ignore rollup config or only use part fields when we compute hash |
That's interesting... Really we don't need rollup config in the hash in watch mode, since it can't change there, but such hash would be incompatible with normal builds where we do want rollup config in case it changes... We can either use a separate hash strategy in watch mode (with a second set of cache artifacts), or a better way would be to pre-hash rollup config and only regenerate that in watch mode if config file changes (if we can/need to detect that). The question is, what does rollup do to handle config changes in watch mode? Does it rebuild everything? Or ignores any changes? |
Workaround, use |
Cache is no longer used during watch mode in 0.35.0 now |
Thanks for providing some profiling! I knew the Rollup config hashing was slow and buggy (see also #228) but hadn't ever seen it be that slow 😬 Resolving the root cause here is a bit complicated (as #228 alludes to), as a change in any part of the config could result in a different output. Conservatively busting the cache on any change is safer. Limiting which parts of the config are cached could make the cache busting more inaccurate, resulting in more stale results The cache is buggy and slow enough (especially as it rolls too often) though that I wonder if we should just make it an opt-in experimental feature instead. It has enough value for larger use-cases that I'm hesitant to remove it wholesale, but it seems to be more problematic than useful on average. |
Yeah, I'm leaning towards removing or reworking cache too (maybe implementing caching DocumentRegistry). I've recently seen some errors being hidden until a clean build in my own projects. |
Curious what you mean by this? As in a custom implementation with filesystem caching? Something like that is mentioned in the TS Compiler docs, but never thought about implementing that 👀 I wonder how much that would increase performance 🤔 In #388 I did make the optimization for The dependency graph rpt2 has sounds more advanced in theory (but in practice could be less efficient), and I think something like it will still be necessary to implement |
Thinking back, I did at one point consider splitting out the cache implementation into its own library. That way different implementations could be plugged in and could be shared with other TS libraries. |
Yeah, I expect typescript to have its own cache busting logic for document registry (based on compiler options and other parameters some DocumentRegistry calls take I assume), and that might handle some of the dependency tree logic we are trying to build in cache, but rollup potentially adds other reasons to retranspile by changing plugins that affect imports, so getting away from monitoring rollup config changes would be hard anyway... |
Not sure if moving cache into its own library would give us much, since I expect most bugs to be related to failing to detect reasons to break cache and that requires full integration into pipeline. Unless we can make it a separate rollup plugin somehow? |
Troubleshooting
Does
tsc
have the same output? If so, please explain why this is incorrect behaviorDoes your Rollup plugin order match this plugin's compatibility? If not, please elaborate
Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction
What happens and why it is incorrect
Environment
Versions
:rollup.config.js
:tsconfig.json
:package.json
plugin output with verbosity 3
:detail
When rebuilding, rollup-plugin-typescript2 computes a hash key for the cache. One portion of the hash is the Rollup config, which is actually so big of an object that it is a significant performance degradation to compute its hash.
Referencing this part of code:
rollup-plugin-typescript2/src/tscache.ts
Lines 93 to 102 in f6db596
In the profiling below, we can see that computing the hash compute takes up almost all of the time, about 20s:
The text was updated successfully, but these errors were encountered: