Skip to content

perf(source-map): add value source offset index - #122

Merged
luojiyin1987 merged 1 commit into
masterfrom
perf/value-source-offset-index
Sep 26, 2026
Merged

luojiyin1987 merged 1 commit into
masterfrom
perf/value-source-offset-index

Conversation

@luojiyin1987

Copy link
Copy Markdown
Contributor

Summary

  • Add MarkdownSourceMap.getValueSourceIndex().
  • Add the public MarkdownValueSourceIndex type.
  • Return primitive source offsets without creating point or range objects.
  • Use a cursor for forward scans.
  • Use binary search for reverse and random access.
  • Preserve ownership, mutation, bounds, and atomic-boundary checks.
  • Document the API and update the API report.

Benchmark

The benchmark used Node 24.15.0.
It used 10,000 newline candidates and 50,000 queries per sample.
It ran 12 alternating A/B samples in one process.

Query Median Mean
getSourceRange(node, index, index) 12.65 ms 12.70 ms
sourceOffsetAt(index) 3.03 ms 3.03 ms

The median time decreased by 76.0%.
The source index was 4.17 times faster.
This benchmark measures boundary lookup only.
It does not claim a full lint runtime improvement.

Tests

  • pnpm run build
  • pnpm run lint
  • pnpm test
  • 23 test suites passed.
  • 1,976 tests passed.

Security

No sensitive data is included.
No redaction was required.

Closes #121.

@luojiyin1987
luojiyin1987 merged commit 46f6b5d into master Sep 26, 2026
14 checks passed
@luojiyin1987
luojiyin1987 deleted the perf/value-source-offset-index branch September 26, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(source-map): add a value-to-source offset index

1 participant