-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
perf(swc_ecma_transforms_base/rename): use FxHashMap in concurrent child aggregation #11666
Copy link
Copy link
Open
Description
Summary
In the concurrent-renamer path, child rename maps are built with std::collections::HashMap and then merged into an FxHashMap.
This introduces avoidable hasher overhead and rehashing in a path explicitly chosen for large rename workloads.
Evidence
crates/swc_ecma_transforms_base/src/rename/analyzer/scope.rs:
- Concurrent branch allocates std map per child: lines 247-259.
- Results are flattened into
to: FxHashMap<Id, V>: lines 263-264. - This branch is selected when
parallelis true (high-cost rename cases).
Why this is a perf issue
Using std hash maps here means:
- slower hashing during child map build (SipHash),
- and extra hashing cost again when reinserting into
FxHashMap.
For large scopes with many child bindings this adds measurable overhead to the parallel fast path.
Suggested direction
- Use
FxHashMap<Id, V>fornew_mapin the concurrent branch. - Optionally reserve capacity from child scope queue size when available.
Notes
Static-analysis report only (no benchmark attached yet).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels