Skip to content

perf(semantic): replace scope interval tree with pre-order index - #12016

Merged
ematipico merged 3 commits into
mainfrom
codspeed/optim-scope-range-index
Sep 29, 2026
Merged

ematipico merged 3 commits into
mainfrom
codspeed/optim-scope-range-index

Conversation

@codspeed

@codspeed codspeed Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace rust_lapper::Lapper scope lookups in biome_js_semantic with a pre-order ScopeRangeIndex.

Scope ranges are properly nested, so the new index sorts entries by start ascending/end descending, de-duplicates identical ranges to preserve the existing behavior, and stores each entry's closest enclosing scope. Lookups use binary search followed by an enclosing-scope walk (O(log n + depth) instead of scanning all intervals). The builder-side range map and the rust-lapper dependency are removed.

Validation

  • cargo test -p biome_js_semantic
  • cargo test -p biome_module_graph
  • cargo test -p biome_js_analyze
  • cargo clippy -p biome_js_semantic --all-targets -- -D warnings
  • cargo fmt --all -- --check

All passed with no tracked snapshot changes.

CodSpeed comparison

Measured with the same local CPU-simulation setup on the biome_module_graph suite:

The comparison reports 10 improvements, 32 unchanged benchmarks, and no regressions. Highlights include:

  • index_d_ts[astro_server.mjs]: 151.2 ms → 69.6 ms (×2.2)
  • bench_index_d_ts_salsa_end_to_end[astro_server.mjs]: 184.5 ms → 102.5 ms (+80.0%)
  • bench_index_d_ts_salsa_incremental_first_run: 490.5 ms → 304.9 ms (+60.9%)

A walltime run was attempted locally but could not complete: dedicated macro runners are unavailable for this repository owner, and the standard-runner LTO build was stopped before benchmark execution. The validated comparison above is CPU simulation, matching the repository's benchmark workflow mode.

@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0c993c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-win32-x64 Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/wasm-web Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the L-JavaScript Language: JavaScript and super languages label Sep 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 49797 49797 0
Passed 48773 48773 0
Failed 1024 1024 0
Panics 0 0 0
Coverage 97.94% 97.94% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

markdown/commonmark

Test result main count This PR count Difference
Total 652 652 0
Passed 652 652 0
Failed 0 0 0
Panics 0 0 0
Coverage 100.00% 100.00% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6322 6322 0
Passed 2147 2147 0
Failed 4175 4175 0
Panics 0 0 0
Coverage 33.96% 33.96% 0.00%

ts/babel

Test result main count This PR count Difference
Total 662 662 0
Passed 592 592 0
Failed 70 70 0
Panics 0 0 0
Coverage 89.43% 89.43% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17646 17646 0
Passed 13449 13449 0
Failed 4197 4197 0
Panics 0 0 0
Coverage 76.22% 76.22% 0.00%

yaml/yaml-test-suite

Test result main count This PR count Difference
Total 402 402 0
Passed 402 402 0
Failed 0 0 0
Panics 0 0 0
Coverage 100.00% 100.00% 0.00%

@ematipico ematipico self-assigned this Sep 29, 2026
@codspeed

codspeed Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Merging this PR will regress 1 benchmark

⚠️ 3 benchmarks measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. These results are not comparable, so they count as unchanged.

Preventing compiler optimizations

⚡ 9 improved benchmarks
❌ 1 regressed benchmark
✅ 348 untouched benchmarks
⏩ 6 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ bench_recursive_alias_member_lookup[path_value] 751.2 µs 807.7 µs -6.99%
⚡ index_d_ts[astro_server.mjs] 486.7 ms 233.9 ms ×2.1
⚡ bench_index_d_ts_salsa_end_to_end[astro_server.mjs] 589.3 ms 336.3 ms +75.25%
⚡ bench_index_d_ts_salsa_incremental_first_run 1.6 s 1 s +58.91%
⚡ index_d_ts[RedisCommander.d.ts] 379 ms 262.5 ms +44.42%
⚡ index_d_ts[@next/font/google/index.d.ts] 755.2 ms 537.3 ms +40.57%
⚡ bench_index_d_ts_salsa_end_to_end[RedisCommander.d.ts] 429.4 ms 312 ms +37.61%
⚡ bench_index_d_ts_salsa_end_to_end[@next/font/google/index.d.ts] 930.8 ms 715.3 ms +30.13%
⚡ bench_normalize_local_alias 115.4 µs 94 µs +22.8%
⚡ index_d_ts[react/index.d.ts] 57.2 ms 53.6 ms +6.81%
⚠️ grit_query_anchor_kinds[code_snippet] < 1 ns < 1 ns N/A
⚠️ grit_query_anchor_kinds[metavariable] < 1 ns < 1 ns N/A
⚠️ grit_query_anchor_kinds[or_pattern] < 1 ns < 1 ns N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codspeed/optim-scope-range-index (0c993c8) with main (994e40f)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codspeed
codspeed Bot requested a review from ematipico September 29, 2026 09:10
@ematipico
ematipico marked this pull request as ready for review September 29, 2026 09:10
@ematipico

ematipico commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

I added a changeset because the savings are real, and users will benefit.

@ematipico
ematipico merged commit 09d4000 into main Sep 29, 2026
44 checks passed
@ematipico
ematipico deleted the codspeed/optim-scope-range-index branch September 29, 2026 10:13
@github-actions github-actions Bot mentioned this pull request Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants