Repository navigation
Conversation
To see where a build spends its time, RESCRIPT_TRACE=<file> now makes the build write a Chrome trace event file when it exits, which Perfetto (ui.perfetto.dev) shows as a timeline: - The main track has a span per dependency graph (parse, compile, namespaces, format) and per scheduler step, and counters for the tasks that are ready and running. - Each worker slot has a track with a span per compiler request, named after its input file, with its allocated words and the garbage collections during it as arguments. Implementations get child spans for type checking and code generation, from a domain-local hook that Js_implementation calls once typing is done. Times are whole microseconds, so spans that share an end point nest exactly. A command that records nothing, such as a clean, leaves an earlier trace alone. Without the variable, the scheduler only checks a flag per step and the compiler calls an empty hook per implementation. Clean builds of tests/tests take the same time as before (0.28 s); with the trace on they take 0.305 s, mostly for writing its 1 MB file. A test in rewatch-ocaml/tests/run.sh checks the trace's spans and nesting and that traced builds write the same JavaScript. 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>
A trace of a real project showed workers spending 20-25% of their time in tasks but outside compiler requests. That time is the task's result handler, which publishes the files the request wrote; it now gets a "publish" span after the request on the worker's track. On tests/tests it takes 398 ms against 1349 ms of compiler requests. The trace test checks that the span follows each implementation's request. 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>
A clean build writes thousands of artifacts through write_file_atomic. Each write created the temporary file, closed it, set its mode by path, opened it again to write and then renamed it. Now the temporary file is created once with O_EXCL, given mode 0644 with fchmod, written through that descriptor, closed and renamed. Windows has no fchmod, so the new Platform.set_file_permissions does nothing there. On tests/tests with one compiler worker, the publish spans take 74 ms instead of 90 ms. With 8 workers they stay at about 385 ms. Review: Does a failed write still remove its temporary file? Yes, any exception closes the descriptor if it is still open, removes the file and re-raises. A test covers a missing directory and a directory as the destination. 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>
|
@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. |
Changelog🚀 New Feature
💅 Polish
Semantic Diff3 commits · Full page Write a build trace for Perfetto with RESCRIPT_TRACE67ea24a · cknitt + Claude · Nov 23, 2026, 20:08 UTC To see where a build spends its time, RESCRIPT_TRACE=<file> now makes the build write a Chrome trace event file when it exits, which Perfetto (ui.perfetto.dev) shows as a timeline: - The main track has a span per dependency graph (parse, compile, namespaces, format) and per scheduler step, and counters for the tasks that are ready and running. - Each worker slot has a track with a span per compiler request, named after its input file, with its allocated words and the garbage collections during it as arguments. Implementations get child spans for type checking and code generation, from a domain-local hook that Js_implementation calls once typing is done. Times are whole microseconds, so spans that share an end point nest exactly. A command that records nothing, such as a clean, leaves an earlier trace alone. Without the variable, the scheduler only checks a flag per step and the compiler calls an empty hook per implementation. Clean builds of tests/tests take the same time as before (0.28 s); with the trace on they take 0.305 s, mostly for writing its 1 MB file. A test in rewatch-ocaml/tests/run.sh checks the trace's spans and nesting and that traced builds write the same JavaScript. Show publishing as a span in the build tracee15e3b3 · cknitt + Claude · Nov 24, 2026, 07:56 UTC A trace of a real project showed workers spending 20-25% of their time in tasks but outside compiler requests. That time is the task's result handler, which publishes the files the request wrote; it now gets a "publish" span after the request on the worker's track. On tests/tests it takes 398 ms against 1349 ms of compiler requests. The trace test checks that the span follows each implementation's request. Write build artifacts with fewer file-system calls3eb0b7c · cknitt + Claude · Nov 24, 2026, 16:36 UTC A clean build writes thousands of artifacts through write_file_atomic. Each write created the temporary file, closed it, set its mode by path, opened it again to write and then renamed it. Now the temporary file is created once with O_EXCL, given mode 0644 with fchmod, written through that descriptor, closed and renamed. Windows has no fchmod, so the new Platform.set_file_permissions does nothing there. On tests/tests with one compiler worker, the publish spans take 74 ms instead of 90 ms. With 8 workers they stay at about 385 ms. Review
|
|
Codex Review: Didn't find any major issues. 🎉 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". |
✅ Compiler benchmarksAllocated wordsIn total: 637,404,885 → 637,313,339 (-0.01%). Generated projects: 629,030,488 → 628,852,128 (-0.03%).
InstructionsIn total: 9,221,420,665 → 9,221,449,830 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 25,987,723 → 25,987,723 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 3eb0b7c compared with base aacaf72 in this run. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9408 +/- ##
=======================================
Coverage 82.21% 82.22%
=======================================
Files 460 462 +2
Lines 65552 65577 +25
=======================================
+ Hits 53892 53919 +27
+ Misses 11660 11658 -2
🚀 New features to boost your workflow:
|
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-9408 |
Based on #9402: this branch contains #9402's two commits, so it targets
masterto get CI and preview packages; only the last commit belongs to this PR.A clean build writes thousands of artifacts (.ast, .iast, .cmi, .cmt, .cmti) through
File_util.write_file_atomic. On a real project a write costs about 190 µs with one worker and 450 µs with 8 workers, nearly independent of file size, so the file-system calls dominate.Each write created the temporary file with
Filename.temp_file, which closes it, then set its mode withchmodby path, opened it again to write, closed it and renamed it. Now the temporary file is created once withO_EXCLunder the same.rewatch-write-prefix, given mode 0644 withfchmod, written through that descriptor, closed and renamed. That is 5 system calls instead of 8. A name that already exists gets a new random name, as inFilename.temp_file. A failed write still closes the descriptor and removes the temporary file.Mode 0644 still holds under any umask.
Unix.fchmodis not available on Windows, so the newPlatform.set_file_permissionsdoes nothing there; Windows has no umask andopenfilealready makes the file writable. The Windows fallback inCompiler_process.write_heldis unchanged: a failed rename still raises, removes the temporary file, and the artifact is written in place.Measured on tests/tests (690 modules, linux-arm64), with the "publish" spans from #9402, 5 alternating clean builds each (median):
With 8 workers the publish time does not change, so there the time goes elsewhere. Across 10 alternating clean builds with 8 workers, wall time is 0.29 s in both (min 0.28 s before, 0.27 s after) and CPU time (user + sys) is 1.40 s before and 1.37 s after.
strace -cwith one worker shows 2140 feweropenat,closeandlseekcalls, andfchmodin place offchmodat. All 3484 files under lib/ and the .mjs files are byte-identical, with the same modes.New tests in
file_util_tests.ml: an atomic write creates a file and its parent directories, replaces a file with empty and with 200 KB contents, sets 0644 under umask 077, and leaves no temporary file after success, after writing into a missing directory, and after writing over a directory.🤖 Generated with Claude Code
https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH