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>
Why:
A proof of concept of a build that, like a Rust port of the compiler
would, writes only the JavaScript. With RESCRIPT_NO_ARTIFACTS=1 the
ASTs, interfaces, .cmj files and namespace maps of the packages being
built stay in memory for the whole process. A new process builds
everything again; a watch session keeps them across rebuilds. Without
the variable nothing changes.
Build_file_store can now keep selected paths in memory only. Each has a
modification time, set when it is written or published changed, so the
freshness rules work as with files on disk. These files survive the end
of a build, while everything read from disk is dropped as before and the
generation still changes, so type-checker caches start over each build.
Held writes of a failed request fall back to the file kept before them.
forget keeps such a file, like a file on disk, and the new remove deletes
it.
The build system marks the artifact directories of the packages it
builds as memory only; the runtime's shipped interfaces are still read
from disk. In this mode it compiles with -bs-no-bin-annot, and an empty
typed tree in memory marks a module compiled. The artifact index lists
the store instead of the directories, and dating an AST back changes its
time in memory. It skips compiler-info.json, .sourcedirs.json and the
clean after a compiler change. The compiler now reads the namespace map
through the store.
On tests/tests (690 modules, linux-arm64), a clean build takes 0.23 s
instead of 0.29 s (median of 10), and 0.89 s instead of 1.05 s with one
domain. Peak memory is a little lower, as no typed trees are made.
Editor tooling and gentype don't work in this mode.
A test in rewatch-ocaml/tests/run.sh builds a namespace and a dependency
in both modes, and checks that the JavaScript is the same and that no
artifact files are written.
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 |
Changelog🚀 New Feature
🏠 Internal
Semantic Diff4 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. Build without artifact files when RESCRIPT_NO_ARTIFACTS=107b7b0a · cknitt + Claude · Nov 24, 2026, 18:12 UTC
Build_file_store can now keep selected paths in memory only. Each has a modification time, set when it is written or published changed, so the freshness rules work as with files on disk. These files survive the end of a build, while everything read from disk is dropped as before and the generation still changes, so type-checker caches start over each build. Held writes of a failed request fall back to the file kept before them. forget keeps such a file, like a file on disk, and the new remove deletes it. The build system marks the artifact directories of the packages it builds as memory only; the runtime's shipped interfaces are still read from disk. In this mode it compiles with -bs-no-bin-annot, and an empty typed tree in memory marks a module compiled. The artifact index lists the store instead of the directories, and dating an AST back changes its time in memory. It skips compiler-info.json, .sourcedirs.json and the clean after a compiler change. The compiler now reads the namespace map through the store. On tests/tests (690 modules, linux-arm64), a clean build takes 0.23 s instead of 0.29 s (median of 10), and 0.89 s instead of 1.05 s with one domain. Peak memory is a little lower, as no typed trees are made. Editor tooling and gentype don't work in this mode. A test in rewatch-ocaml/tests/run.sh builds a namespace and a dependency in both modes, and checks that the JavaScript is the same and that no artifact files are written. ✨ Let RESCRIPT_WORKER_MINOR_HEAP set the worker minor heap sizee2d6634 · cknitt + Claude · Nov 24, 2026, 20:03 UTC · new To measure how the size of the workers' minor heaps affects real builds, RESCRIPT_WORKER_MINOR_HEAP sets it in words, optionally with a k or M suffix (for example 16M). Without it the workers keep 4M words. This is a knob for experiments on this proof of concept. On tests/tests (690 modules, 8 workers, no artifacts), 8M words take 0.22 s instead of 0.23 s for 200 MB more peak memory; larger sizes change nothing. |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07b7b0a4ab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| if | ||
| (not No_artifacts.enabled) | ||
| && Compiler_info.needs_clean package_context package.config |
There was a problem hiding this comment.
Invalidate retained artifacts when compiler configuration changes
With RESCRIPT_NO_ARTIFACTS=1, changing compiler-affecting configuration during rescript watch can report a successful rebuild while leaving JavaScript compiled with the old settings. Configuration edits trigger Full_watch_attempt, but the store retains the previous ASTs, interfaces, and compile timestamps, and this guard bypasses the configuration-hash invalidation previously provided by Compiler_info.needs_clean. If source paths and output specifications stay unchanged—for example, when changing JSX settings—the freshness checks in Package_compilation.prepare can therefore skip every module. Preserve the previous configuration fingerprint in memory and invalidate the affected artifacts when it changes; this is separate from the documented limitation concerning cleanup of previous package-spec outputs.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9409 +/- ##
==========================================
- Coverage 82.21% 82.15% -0.06%
==========================================
Files 460 462 +2
Lines 65552 65628 +76
==========================================
+ Hits 53892 53918 +26
- Misses 11660 11710 +50
🚀 New features to boost your workflow:
|
✅ Compiler benchmarksAllocated wordsIn total: 637,411,281 → 638,133,483 (+0.11%). Generated projects: 629,040,931 → 629,532,435 (+0.08%).
InstructionsIn total: 9,221,420,275 → 9,222,479,660 (+0.01%).
1 more change
Output sizeIn total: 25,987,723 → 25,987,735 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request e2d6634 compared with base aacaf72 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-9409 |
To measure how the size of the workers' minor heaps affects real builds, RESCRIPT_WORKER_MINOR_HEAP sets it in words, optionally with a k or M suffix (for example 16M). Without it the workers keep 4M words. This is a knob for experiments on this proof of concept. On tests/tests (690 modules, 8 workers, no artifacts), 8M words take 0.22 s instead of 0.23 s for 200 MB more peak memory; larger sizes change nothing. 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>
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.This is a proof of concept. With
RESCRIPT_NO_ARTIFACTS=1, the build system writes only the JavaScript, like a Rust port of the compiler would. ASTs, interfaces,.cmjfiles and namespace maps stay in memory for the life of the process. Without the variable nothing changes.What the mode does
rescript buildbuilds everything in every new process, since nothing is kept on disk.rescript watchkeeps the artifacts in memory across rebuilds. Incremental rebuilds compile the same modules as in the normal mode..compiler.logtouch the disk. No.ast,.iast,.cmi,.cmj,.cmt,.cmti,.mlmap,compiler-info.jsonor.sourcedirs.jsonare written.What changed
Build_file_storecan keep chosen paths in memory only. Each such file has a modification time, set when it is written or published with new contents. So the freshness rules work as they do with files on disk.forgetkeeps a file in memory, like a file on disk; the newremovedeletes it.No_artifactsmodule).-bs-no-bin-annot. An empty typed tree in memory marks a module compiled.Compile_assetslists the store instead of the directories. Dating an AST back changes its time in memory. The disk fallbacks inBuild_freshnessandAst_headerare off in this mode.compiler-info.json,.sourcedirs.jsonand the clean after a compiler change.Js_implementation.implementation_map), so it can live in memory too.Results (linux-arm64)
tests/tests(690 modules), 10 alternating clean builds per mode,/usr/bin/time:Part of the gain comes from not making typed trees at all.
The JavaScript of a clean build is the same in both modes (md5 of every
.mjs).A watch of the same project: an interface change of
test_utils.rescompiled 211 modules in both modes, and an implementation-only change then compiled 2. Peak RSS of the watch process was 533 MB, against 599 MB in the normal mode. The JavaScript matched a clean build.A watch scenario on a small namespaced project gave the same compiles in both modes: an implementation change without an interface change does not recompile dependents, an interface change does, a type error and its fix recover, an added file is compiled, a deleted file's JavaScript is removed, and a module that names it then fails with "can't be found". The final JavaScript matched a clean normal build.
The integration suite (
rewatch/tests), run test by test with the variable set: 46 of 60 tests pass, among them all watch tests but one. The 14 failures are expected for this proof of concept:features/04also run a new process after the change. It has no ASTs that tell which source wrote the old JavaScript, so that file stays on disk. Inside a watch session it is removed.compile/21andwatch/04change the package-specs. The outputs of the previous specs are found only throughcompiler-info.json, which this mode does not write.gentype/01needs typed trees.Known limitations
.cmifiles or.sourcedirs.jsonon disk.rescript buildis a full build..cmjfiles of the project stay in memory. Fortests/teststhis was less than the typed trees the normal mode makes.New tests
rewatch-ocaml/tests/run.shbuilds the namespace and dependency fixtures in both modes, and checks that the JavaScript is the same and that no artifact files are written.🤖 Generated with Claude Code
https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH