[PR #955] [MERGED] perf(javascript): reduce analysis and source-map work #2532

Closed
opened 2026-10-17 21:07:15 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/955
Author: @morluto
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @morluto

Base: main ← Head: codex/javascript-analysis-performance


📝 Commits (2)

  • 20a696f perf(javascript): reduce semantic traversal overhead
  • 6668bda perf(source-maps): reuse validated regular map rows

📊 Changes

6 files changed (+59 additions, -10 deletions)

View changed files

📝 src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts (+25 -0)
📝 src/domain/javascript/javascriptSemanticCalls.ts (+1 -3)
📝 src/domain/javascript/javascriptSemanticTraversal.test.ts (+13 -0)
📝 src/domain/javascript/javascriptSemanticTraversal.ts (+14 -6)
📝 src/javascript/sourceMaps/TraceSourceMap.test.ts (+3 -0)
📝 src/javascript/sourceMaps/TraceSourceMap.ts (+3 -1)

📄 Description

Summary

This PR reduces repeated work in JavaScript analysis and source-map tracing. Semantic call-result collection now looks up assigned bindings by their existing ID index, and AST traversal gathers children in visitor-key order without allocating flatMap/filter callback arrays. Regular source maps reuse the decoded rows already validated during admission.

Performance evidence

Five interleaved samples on Node v24.18.0 / macOS arm64 showed median full semantic analysis times of 934 ms to 675 ms for the generated 3,000-handler module and 378 ms to 277 ms for the installed Babel parser source. Both complete public IR results matched exactly by serialized byte length and SHA-256. The synthetic module is intentionally effect-heavy; the source-map change is described as avoiding a repeated decode pass and is not assigned a wall-time improvement claim.

Source-map verification

npm run verify:browser:source-maps passed with caller-supplied Chrome and the isolated esbuild 0.25.10 fixture compiler. It exercised real Chrome capture, script export, and public source-map point tracing through CLI and stdio MCP. Four public point cases passed, including preservation of caller-selected URL context. Tracing did not refetch the selected source map.

Checks

  • npm run build:cached
  • npm run test:local -- src/javascript/sourceMaps/TraceSourceMap.test.ts src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts src/domain/javascript/javascriptSemanticTraversal.test.ts (74 tests)
  • npm exec vitest -- run --project domain (116 files, 1,394 tests)
  • npm run check:fast
  • npm run format:check (1,764 files)
  • npm run docs:check

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/955 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/javascript-analysis-performance` --- ### 📝 Commits (2) - [`20a696f`](https://github.com/morluto/rea/commit/20a696f0dd994447599fc55aafef8ade52cddde7) perf(javascript): reduce semantic traversal overhead - [`6668bda`](https://github.com/morluto/rea/commit/6668bda46a0a15e8935a73d6126bc594ebea535f) perf(source-maps): reuse validated regular map rows ### 📊 Changes **6 files changed** (+59 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts` (+25 -0) 📝 `src/domain/javascript/javascriptSemanticCalls.ts` (+1 -3) 📝 `src/domain/javascript/javascriptSemanticTraversal.test.ts` (+13 -0) 📝 `src/domain/javascript/javascriptSemanticTraversal.ts` (+14 -6) 📝 `src/javascript/sourceMaps/TraceSourceMap.test.ts` (+3 -0) 📝 `src/javascript/sourceMaps/TraceSourceMap.ts` (+3 -1) </details> ### 📄 Description ## Summary This PR reduces repeated work in JavaScript analysis and source-map tracing. Semantic call-result collection now looks up assigned bindings by their existing ID index, and AST traversal gathers children in visitor-key order without allocating `flatMap`/`filter` callback arrays. Regular source maps reuse the decoded rows already validated during admission. ## Performance evidence Five interleaved samples on Node v24.18.0 / macOS arm64 showed median full semantic analysis times of 934 ms to 675 ms for the generated 3,000-handler module and 378 ms to 277 ms for the installed Babel parser source. Both complete public IR results matched exactly by serialized byte length and SHA-256. The synthetic module is intentionally effect-heavy; the source-map change is described as avoiding a repeated decode pass and is not assigned a wall-time improvement claim. ## Source-map verification `npm run verify:browser:source-maps` passed with caller-supplied Chrome and the isolated esbuild 0.25.10 fixture compiler. It exercised real Chrome capture, script export, and public source-map point tracing through CLI and stdio MCP. Four public point cases passed, including preservation of caller-selected URL context. Tracing did not refetch the selected source map. ## Checks - `npm run build:cached` - `npm run test:local -- src/javascript/sourceMaps/TraceSourceMap.test.ts src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts src/domain/javascript/javascriptSemanticTraversal.test.ts` (74 tests) - `npm exec vitest -- run --project domain` (116 files, 1,394 tests) - `npm run check:fast` - `npm run format:check` (1,764 files) - `npm run docs:check` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:07:15 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2532
No description provided.