Repository navigation
Conversation
A trace of a real project showed compiler workers spending 16-25% of their time publishing outputs, and each write taking twice as long with 8 workers writing at once. With RESCRIPT_BACKGROUND_WRITES=1, the held outputs (.ast, .iast, .cmi, .cmt, .cmti) now go to a queue that one writer domain writes in order, so workers go back to compiling. The build file store keeps serving the contents until they are on disk: the writer's atomic write does not make the store forget the path, and a typed tree leaves the store only once it is written. The parse and compile phases wait for the queue when they end, and the first write error fails the build there. Without the variable every write runs right away, as before. With RESCRIPT_TRACE, every write is now a span named after its file with its size and kind, on the writer's track or inside the worker's publish span. On tests/tests (690 modules), clean builds with the writer leave the same 3484 output files and take 0.270 s instead of 0.295 s (median of 10). A write takes 47-115 us on the writer and 169-201 us with 8 workers writing, and the build never waited for the writer. 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 Prototype writing build outputs on a background domain44e06fb · cknitt + Claude · Nov 24, 2026, 14:35 UTC A trace of a real project showed compiler workers spending 16-25% of their time publishing outputs, and each write taking twice as long with 8 workers writing at once. With RESCRIPT_BACKGROUND_WRITES=1, the held outputs (.ast, .iast, .cmi, .cmt, .cmti) now go to a queue that one writer domain writes in order, so workers go back to compiling. The build file store keeps serving the contents until they are on disk: the writer's atomic write does not make the store forget the path, and a typed tree leaves the store only once it is written. The parse and compile phases wait for the queue when they end, and the first write error fails the build there. Without the variable every write runs right away, as before. With RESCRIPT_TRACE, every write is now a span named after its file with its size and kind, on the writer's track or inside the worker's publish span. On tests/tests (690 modules), clean builds with the writer leave the same 3484 output files and take 0.270 s instead of 0.295 s (median of 10). A write takes 47-115 us on the writer and 169-201 us with 8 workers writing, and the build never waited for the writer. |
✅ Compiler benchmarksAllocated wordsIn total: 637,002,064 → 637,233,177 (+0.04%). Generated projects: 629,067,623 → 629,496,976 (+0.07%).
InstructionsIn total: 9,221,409,971 → 9,221,409,971 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 25,976,823 → 25,976,823 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 44e06fb compared with base e15e3b3 in this run. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## build-trace #9406 +/- ##
===============================================
- Coverage 82.22% 82.21% -0.02%
===============================================
Files 462 461 -1
Lines 65577 65556 -21
===============================================
- Hits 53919 53895 -24
- Misses 11658 11661 +3 🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
Prototype for measuring: this is opt-in and only meant to find out whether writing outputs off the compiler workers speeds up real builds.
A build trace (#9402) of a real project showed compiler workers spending 16–25% of their time publishing outputs. Each write also took twice as long with 8 workers writing at once.
With
RESCRIPT_BACKGROUND_WRITES=1, the held outputs (.ast,.iast,.cmi,.cmt,.cmti) go to a queue that one writer domain writes in order, and the workers go back to compiling:With
RESCRIPT_TRACE, every write is a span named after its file, with its size and kind. It sits on awritertrack, or inside the worker'spublishspan when the writer is off.On
tests/tests(690 modules, linux-arm64):Open questions before this could become the default:
.cmtfiles at all.Stacked on #9402.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH