webpack
webpack copied to clipboard
Hoist RegExp Literals in SourceMapDevToolPlugin
Bug report
What is the current behavior? The use of RegExp literals create unnecessary object references/allocations especially in iterated hot paths like SourceMapDevToolPlugin. We should hoist these to the top of file and give them useful names so people understand what the heck they do.
If the current behavior is a bug, please provide the steps to reproduce. Some Examples:
Mapping over a RegExp literal: https://github.com/webpack/webpack/blob/3ad4fcac25a976277f2d9cceb37bc81602e96b13/lib/SourceMapDevToolPlugin.js#L419
Big Async ForEach Statement with multiple RexExp Literal statements: https://github.com/webpack/webpack/blob/3ad4fcac25a976277f2d9cceb37bc81602e96b13/lib/SourceMapDevToolPlugin.js#L384-L551
What is the expected behavior? Less memory allocation, less garbage collection triggered.
Happy to PR this. There are quite a few of these examples still lying around webpack that should be cleaned up but I'll start with this.
This makes sense to me - I wonder if you have any perf traces or anything that could show any marked improvement from this change?
This makes sense to me - I wonder if you have any perf traces or anything that could show any marked improvement from this change?
I'll try and find something to show. I won't have before and after, however I'll be able to show the hot path from a memory profiling trace.
@markjm Here is an example of mem allocation hotpath if this helps. This tree is during the forEach calls referenced in the PR.
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
bump
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
@TheLarkInn Do we still need it?
I'll address PR comments and then we can reopen and close once we merge it.