Latest Results
perf(ecma): reduce transformer compat overhead (#11856)
**Description:**
Optimizes ECMA transformer/compat benchmark hot paths from
CodSpeed/Callgrind data without touching `swc_es_*` crates.
Changes:
- Reduce ES2015 block-scoping `Id` cloning in captured-loop and usage
tracking.
- Skip unused common hook state and avoid building full
`Options::into_pass()` pipelines for one-off compat wrappers.
- Route simple compat wrappers through direct visitors/passes for
optional catch binding, export namespace, and standalone regexp.
- Stop syntax detectors after the first match.
- Skip ES2022 private visitors and `#x in obj` handling when the input
has no relevant private syntax.
- Keep the final direct sticky-regexp options initialization
clippy-clean.
- Scope generated var declarations inside concise arrow bodies without
restoring the full statement injector hot path.
CodSpeed / Callgrind IR data (`swc_ecma_transforms_typescript` `compat`,
`RUST_LOG=off`, `valgrind-3.26.0.codspeed`):
| Step | Aggregate Ir | Delta vs baseline | Notes |
| --- | ---: | ---: | --- |
| Baseline (`753b222fbf`) | 19,480,917 | - | `origin/main` at branch
point |
| After `1d18dbff51` | 19,476,707 | -4,210 (-0.02%) | Avoid storing
captured loop ids |
| After `eeebf21b6d` | 19,470,908 | -10,009 (-0.05%) | Avoid duplicate
usage id clones |
| After `6d333edb06` | 19,076,175 | -404,742 (-2.08%) | Skip unused
common hooks |
| After `eb84fd4900` | 18,281,590 | -1,199,327 (-6.16%) | Use direct
passes for compat wrappers |
| After `80a43c44db` | 18,277,381 | -1,203,536 (-6.18%) | Use direct
visitors for simple passes |
| After `5511f03a5f` | 17,886,208 | -1,594,709 (-8.19%) | Skip private
visitors without private names |
| After `d46a268034` | 17,791,558 | -1,689,359 (-8.67%) | Stop syntax
detectors after a match |
| After `073fbd0455` | 17,499,239 | -1,981,678 (-10.17%) | Skip
private-in pass without brand checks |
| After `1d43d588f3` | 17,499,239 | -1,981,678 (-10.17%) | Clippy-only
cleanup |
| Final (`dfd6421122`) | 17,516,274 | -1,964,643 (-10.08%) | Balance
concise-arrow temp scopes after body rewrites |
Measured and reverted experiments:
- `block_scoping/vars.rs` `FxHashMap`/`FxHashSet` rewrite: `17,794,158
Ir`, slower than the preceding result.
- Runtime regexp split with a scanner fast path: `17,970,703 Ir`, slower
than the preceding result.
**BREAKING CHANGE:**
None.
**Related issue (if exists):**
None.
Verification:
- `git submodule update --init --recursive`
- `cargo fmt --all`
- `cargo clippy --all --all-targets -- -D warnings`
- `cargo test -p swc_ecma_compat_common`
- `PATH="$(pwd)/node_modules/.bin:$PATH" cargo test -p
swc_ecma_compat_es2015`
- `cargo test -p swc_ecma_compat_es2016`
- `cargo test -p swc_ecma_compat_es2017`
- `cargo test -p swc_ecma_compat_es2018`
- `cargo test -p swc_ecma_compat_es2019`
- `cargo test -p swc_ecma_compat_es2020`
- `cargo test -p swc_ecma_compat_es2021`
- `cargo test -p swc_ecma_compat_es2022`
- `cargo test -p swc_ecma_transformer`
- `cargo test -p swc --test projects`
- `CI=1 DIFF=0 RUST_LOG=off cargo test -p swc
fixture____swc_ecma_parser__tests__tsc__objectRest_ts`
- `cargo test -p swc --test projects
fixture_tests__fixture__issues_7xxx__7977__input`
- `cargo test -p swc --test projects
fixture_tests__fixture__issues_9xxx__9110__input`
- `cargo clippy -p swc_ecma_transformer --all-targets -- -D warnings`
- `env RUSTFLAGS="--cfg swc_ast_unknown" cargo check -p
swc_ecma_transforms --features
typescript,react,proposal,optimization,module,compat`
- `cargo codspeed build -p swc_ecma_transforms_typescript --bench
compat`
- `CODSPEED_CARGO_WORKSPACE_ROOT="$(pwd)" RUST_LOG=off valgrind
--tool=callgrind
--callgrind-out-file=target/codspeed/swc_ecma_transforms_typescript_compat.ci-fix-block-scope.callgrind.out
target/codspeed/analysis/swc_ecma_transforms_typescript/compat`
Note: `swc_ecma_compat_es2015` has two exec tests that require `mocha`
on `PATH`; I installed the locked JS dependencies with `pnpm install
--frozen-lockfile` and reran the full crate test with
`node_modules/.bin` on `PATH`. Latest Branches
0%
Timeless0911:david/fix-isolated-dts-parameters 0%
Timeless0911:david/fix-isolated-dts-definite +11%
hardfist:codex/ecma-transform-perf © 2026 CodSpeed Technology