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
Watch mode performance issue in seal
process
#8126
Comments
I've hosted the CPU profiles for the above stats @ https://github.com/MLoughry/webpack-8126-profiles |
🤦 Sorry about that. I've pushed new profiles without breakpoints. The regressions is much less dire, but the areas for improvement remain the same. In a 21.7s rebuild, 11.7s is spent in |
Thanks. I think the slowness is related to this piece of code: Lines 1828 to 1845 in 4c461e2
or this Line 1861 in 4c461e2
The algorithm tracks paths through the ChunkGroups of the application and finds the minimal modules available at each ChunkGroup. Depending on the number of possible paths it can be expensive. The first snippet is entered for each ChunkGroup with the Or the second snippet is responsible for the 7.5s (the Another easy idea is to merge step 4 and 5 and filter Let's start with measuring to figure out if these snippets are nearly responsible for the slowness. The low hanging fruits can be tackled anyway (send a PR). |
I continue to find boneheaded mistakes on my part. Apparently, I was profiling against a version of webpack from May, when I last contributed, rather than the most recent. I've re-profiled, and updated the repo. I've also made changes as I believe you intended, but they're not leading to perf gains as expected. It's entirely probable I misunderstood your suggestsions. Either way, the profiles for those are posted to the same repo (appended with I've opened #8143 for conversation and comments. From my limited profiling, I'm not seeing any improvements. I'll try running more rigorous benchmarks tomorrow, but I wanted to get something back to you before EU Friday. |
If that doesn't help you could try to make Maybe also track some statistics the the algorithm, like the number of Line 1854 in a868789
Technically we could leave the loop before step 2: Line 1858 in a868789
when the same chunkGroup is already queued up again. Maybe track the count how often a chunkGroup is queued up and exit early when count > 0. |
Sorry, I got sidetracked on other projects, but I'm looping back around to this.
I have the stats, but I'm not sure how to interpret them. In our build, on an arbitrary recent commit, we have 5 I implemented a priority queue for your first suggestion in your last post @ https://github.com/MLoughry/webpack/tree/priority-queue. It seems to result in a minor perf gain, but pales in comparison to the monkey patch I mention in #7546. Running a benchmark of 20 rebuilds:
However, I either don't fully understand your second suggestion, or it results in a few snapshot test failures.
|
hmm... I need to look into that... |
btw. this is not valid solution since it's broken. It's shortcutting part of the calculation because it's accidentally modifying the array. |
hmm... I tried your branch, but it completes all StatsCases just fine. I'll create a PR from your branch to let the CI take a look. |
The priority-queue branch doesn't include the second suggestion (which caused the failure). I hadn't committed those changes (and they're currently sitting on my home computer while I'm at work). I agree the monkey-patch is not a valid general-purpose solution, as the change you made that my monkey patch undoes was to fix a legitimate bug. However, if a compilation never had that original issue (as ours doesn't), then the "incorrectness" is irrelevant. |
Could you try this branch: https://github.com/webpack/webpack/tree/perf/chunk-graph |
I am having performance issues with this as well since webpack is going through all unrelated files as well described in #9020. |
I've found interesting thing. If I use As a result, I've decided to use that plugin for both |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Should be fixed #8242, anyway if you still have problem with perf please open new issue with examples, thanks |
is this fixed for you @SleepWalker? |
@sibelius, sorry, I can't recheck it. I have left that project more than a half year ago and have no access to it any more :( |
Feature request
What is the expected behavior?
Watch mode rebuilds would re-use, as much as feasible, the chunk graph from the previous rebuild, to optimize build speed
What is motivation or use case for adding/changing the behavior?
Our project has >12k modules, and using the latest webpack (without monkey-patching alluded to in #7546) results in 75-90s rebuild times. Earlier 4.x builds would rebuild in 15-20s.
When profiling a run where the only change I make to trigger a rebuild is adding a newline to a code file,
79% of time is spent in
Compilation.seal()
, and another 11% in garbage collection.Compilation.processDependenciesBlocksForChunkGroups()
alone counts for 76% of the rebuild time (including GC).How should this be implemented in your opinion?
I have no idea; I'd need guidance from @sokra or someone else more familiar with this area. I looked at simply optimizing
processDependenciesBlocksForChunkGroups
, but couldn't get a good enough understanding of the code to make any meaningful change. I'm also not sure how a rebuild Compilation re-uses data from a previous compilation, so I had no idea how to even begin investigating that route.Are you willing to work on this yourself?
Yes; I've been given a couple dev weeks to work on our team's build performance. However, I don't think I can make any meaningful progress without some guidance.
The text was updated successfully, but these errors were encountered: