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
fix(perf): avoid superfluous timer wrappings in watch mode #5114
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #5114 +/- ##
==========================================
- Coverage 98.94% 98.93% -0.02%
==========================================
Files 226 226
Lines 8429 8431 +2
Branches 2314 2315 +1
==========================================
+ Hits 8340 8341 +1
Misses 32 32
- Partials 57 58 +1
|
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.
Thank you for spotting is. The only issue I see with your implementation is that isWithTimers
now is global state, which means that completely unrelated runs will now also influence each other. Basically if you have a config file with an array of configs, only the plugins in the first config will be instrumented.
Maybe a cleaner approach would be to leave a flag on each instrumented plugin in getPluginWithTimers
, e.g.
function getPluginWithTimers(plugin: any, index: number): Plugin {
if (plugin._hasTimedHooks) return plugin;
plugin._hasTimedHooks = true;
for (const hook of TIMED_PLUGIN_HOOKS) {
if (hook in plugin) {
One could also use a Symbol to hide the flag, or keep a Set<Plugin>
of instrumented plugins as global state. What do you think?
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.
I changed your code as I suggested and will merge it now.
This PR has been released as part of rollup@3.29.1. You can test it via |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
In watch mode, every time bundle starts, inputOptions.plugins will be wrapped in another layer of timer, which will cause incorrect performance timings.