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
parallel is 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> for new_map in the concurrent branch.
- Optionally reserve capacity from child scope queue size when available.
Notes
Static-analysis report only (no benchmark attached yet).
Summary
In the
concurrent-renamerpath, child rename maps are built withstd::collections::HashMapand then merged into anFxHashMap.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:to: FxHashMap<Id, V>: lines 263-264.parallelis true (high-cost rename cases).Why this is a perf issue
Using std hash maps here means:
FxHashMap.For large scopes with many child bindings this adds measurable overhead to the parallel fast path.
Suggested direction
FxHashMap<Id, V>fornew_mapin the concurrent branch.Notes
Static-analysis report only (no benchmark attached yet).