-
-
Notifications
You must be signed in to change notification settings - Fork 763
perf(minifier): speed up single-use symbol substitution by collecting referenced identifiers upfront #17377
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
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #17377 will degrade performance by 7.43%Comparing Summary
Benchmarks breakdown
Footnotes
|
9b34a71 to
b743666
Compare
| // in the target expression. This allows us to quickly skip declarators whose names | ||
| // aren't even present, avoiding expensive tree traversals. | ||
| // For small numbers of declarators, the overhead of creating the HashSet isn't worth it. | ||
| const IDENTIFIER_CACHE_THRESHOLD: usize = 4; |
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.
this is a bit of a hack, but if we're minifying a small file e.g. the files in our benchmarks, creating the ident cache introduces a slowdown and has a negative 5+% perf hit. But if we've got a ton of idents like the one in the linked issue, it's worth it
… referenced identifiers upfront Before checking each declarator for potential inlining, collect all identifier names referenced in the target expression. This allows skipping declarators whose names are not present, avoiding expensive expression tree traversals. This fixes a performance regression where files with many interspersed unused variable declarations (e.g., bundled modules with duplicate imports) would cause O(n*m) traversals where n is the number of statements and m is the number of declarators checked per statement. Closes #17369
b743666 to
ca77d24
Compare
|
q: what do you think about changing |

Before:
After:
Before checking each declarator for potential inlining, collect all identifier names referenced in the target expression. This allows skipping declarators whose names are not present, avoiding expensive expression tree traversals.
This fixes a performance regression where files with many interspersed unused variable declarations (e.g., bundled modules with duplicate imports) would cause O(n*m) traversals where n is the number of statements and m is the number of declarators checked per statement.
Closes #17369