Repository navigation
Conversation
The JS IR mapper Js_record_map rebuilt every node, list and option even when nothing in it changed, and five JS passes run on it, so each pass copied a module's whole JS program although it rewrites little. The mapper now returns a node as it is when all its parts come back physically unchanged, like Lambda_traverse.shallow_map_sharing on the Lambda side; the passes' own overrides (statement lists in flatten, tailcall_inline and record_rest, switches and try in external_shadow) and a string switch in remove_alias do the same. Every function is still called in the same order on the same values. The JS IR has no mutable fields of its own, and the mutable state reachable from it (identifier usage stats, function environments) was already shared by reference before, so no pass sees a difference. JS output and diagnostics are byte-identical on 77 benchmark files, and total allocation drops by 3.2%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH Signed-off-by: Christoph Knittel <ck@cca.io>
Changelog🏠 Internal
Semantic Diff1 commit · Full page Return unchanged JS IR nodes from the mapper and the JS passes3d21237 · cknitt + Claude · Nov 23, 2026, 06:25 UTC The JS IR mapper Js_record_map rebuilt every node, list and option even when nothing in it changed, and five JS passes run on it, so each pass copied a module's whole JS program although it rewrites little. The mapper now returns a node as it is when all its parts come back physically unchanged, like Lambda_traverse.shallow_map_sharing on the Lambda side; the passes' own overrides (statement lists in flatten, tailcall_inline and record_rest, switches and try in external_shadow) and a string switch in remove_alias do the same. Every function is still called in the same order on the same values. The JS IR has no mutable fields of its own, and the mutable state reachable from it (identifier usage stats, function environments) was already shared by reference before, so no pass sees a difference. JS output and diagnostics are byte-identical on 77 benchmark files, and total allocation drops by 3.2%. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9394 +/- ##
==========================================
- Coverage 82.21% 82.18% -0.03%
==========================================
Files 460 460
Lines 65551 65577 +26
==========================================
+ Hits 53891 53896 +5
- Misses 11660 11681 +21
🚀 New features to boost your workflow:
|
🎉 Compiler benchmarksAllocated wordsIn total: 636,516,809 → 624,737,176 (-1.85%). Generated projects: 629,041,809 → 626,381,835 (-0.42%). 🎉 Improvement: 74 benchmarks allocate more than 1% less.
109 more changes
InstructionsIn total: 9,221,447,548 → 9,172,468,895 (-0.53%). 🎉 Improvement: 2 benchmarks execute more than 1% fewer instructions.
Output sizeIn total: 25,962,507 → 25,963,868 (+0.01%). None of the 13 benchmarks changed by 0.1% or more. Pull request 3d21237 compared with base 643e9c0 in this run. |
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9394 |
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Closing: the saved allocations don't make builds faster. 20 alternating clean builds of tests/tests (690 modules) with and without this stack show the same wall and CPU time (±0%, −0.5% CPU) and about 1% less peak memory, and a real-world project shows no difference either. The avoided copies died young, so they cost the GC little. That doesn't pay for the extra mapper code. |
The JS IR mapper
Js_record_maprebuilt every node, list and option even when nothing in it changed. Five JS passes run on it, so each pass copied a module's whole JS program although it rewrites little.Now the mapper returns a node as it is when all its parts come back physically unchanged, like
Lambda_traverse.shallow_map_sharingalready does for Lambda. The passes' own overrides (statement lists inflatten,tailcall_inlineandrecord_rest, switches andtryinexternal_shadow) and a string switch inlam_pass_remove_aliasshare the same way. Every mapper function is still called in the same order on the same values.The JS IR has no mutable fields of its own, and the mutable state reachable from it (identifier usage stats, function environments) was already shared by reference before.
Measured on 77 Belt and
tests/testsfiles: JS output and diagnostics are byte-identical, and compiling allocates 3.2% less.First of three allocation PRs; the stack together saves 4.6%.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH