Skip to content
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

Avoid creating a new array inside doResolve. #427

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

gdborton
Copy link
Contributor

This is a minor optimization that avoids allocating immediately dereferenced arrays when creating a new stack inside doResolve. In the build that I'm testing against, this is called >750k times, which means that we're allocating ~32mb of array data to the heap that's then spent in GC.

It's hard to find optimizations in webpack's codebase, but from my debugging we're spending more time in GC than in any other function.

Here's a jsperf comparing these two ways of creating a one item set:
https://jsperf.app/vureri

And a screenshot of the output for me:
image

Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.99%. Comparing base (1213f32) to head (a10531a).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #427   +/-   ##
=======================================
  Coverage   91.99%   91.99%           
=======================================
  Files          44       44           
  Lines        2123     2124    +1     
  Branches      645      645           
=======================================
+ Hits         1953     1954    +1     
  Misses        138      138           
  Partials       32       32           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexander-akait alexander-akait merged commit 7b6834c into webpack:main Jul 17, 2024
25 checks passed
@alexander-akait
Copy link
Member

Thank you

@gdborton gdborton deleted the avoid-new-set-array branch July 19, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants