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
Unwrap "double errors" to limit cost of Error ctor #14367
Comments
@sokra appreciate your recent perf investigations, so trying to help out where I can. |
First, have you considered fixing this typescript problem by using Otherwise I would rather look into not generating these warnings in first place: Either we add a flag to disable these type of warning, e. g. allowing Or we add a flag to report these warnings only once, e. g. |
Is it specifically the I also agree that it is most valuable to add a flag to disable these, but I dont think this needs to be exclusive with the changes presented in my PR above. I think ensuring perf is optimal (1) for those that dont want to enable that new flag or (2) for any other errors & warnings that may be output from Do you have any concerns accepting these changes in addition to my looking into adding this flag? |
Afaik that's only related to reexporting so |
Bug report
Related to #13532
What is the current behavior?
As discussed in the previous issue, new-ing up Errors has a high cost. This is especially relevant when using a bunch of type-only imports in typescript. Each of these issues causes a
HarmonyLinkingError
, which is then immediately wrapped in aModuleDependencyWarning
. This double-wrapping causes additional overhead due to both of them extendingError
and paying the price of that.What is the expected behavior?
My suggestion is to cut out the usage
ModuleDependency{Warning,Error}
and directly use the errors returned fromgetWarnings
. I have looked through the codebase and dont see anywhere that specifically cares aboutModuleDependencyXXX
error type over other types of WebpackErrors, so this seems like a safe change to make.See cpu trace images below:
Before
After
In our very large typescript-based project webpack build, this change saves ~200ms per recompile. Attaching changes.
Other relevant information:
webpack version: 5.55.1
Node.js version: 16.9.0
Operating System: windows
Additional tools: -
The text was updated successfully, but these errors were encountered: