Repository navigation
Skip copying every props label per JSX element - #9187
Conversation
Changelog💅 Polish
Semantic Diff2 commits · Full page Don't copy every label of a large record per JSX element3b95c9e · JonoPrest · Nov 03, 2026, 07:59 UTC
The label array is now checked in place, and the missing label search is skipped when every label is optional. Records with a required label, like most component props, take the old path. The output is unchanged. Review
Don't copy every label of a large record literal either5578f1e · JonoPrest · Nov 03, 2026, 14:37 UTC
fields_by_position now returns a list built in position order, and the shape array is filled in place. Field expressions are still translated left to right, so the output is unchanged. |
The entry names #9187, so the changelog points at this PR.
|
@codex review |
Codex Review SummaryThis 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9187 +/- ##
=======================================
Coverage 81.73% 81.73%
=======================================
Files 458 458
Lines 65292 65293 +1
=======================================
+ Hits 53367 53368 +1
Misses 11925 11925
🚀 New features to boost your workflow:
|
|
Codex Review: Didn't find any major issues. Breezy! 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". |
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-9187 |
The entry names #9187, so the changelog points at this PR. Signed-off-by: Jono Prest <jjprest@gmail.com>
1adf455 to
d005e48
Compare
|
This is great! Thanks a lot! The second commit is not required. PR links will be added by a script at release time. When I discussed the PR with Claude, it noted:
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
@cknitt thanks! Feedback folded into last commit. |
The entry names #9187, so the changelog points at this PR. Signed-off-by: Jono Prest <jjprest@gmail.com>
b78ba42 to
d4b317a
Compare
Can you drop the "Link the changelog entry to its pull request" commit? |
Why:
JsxDOM.domProps has 591 optional fields. For every lowercase JSX
element, jsx_props_of mapped all of them into a fresh array just to
check whether the record compiles to an array, and typing a record
literal built a 591 entry array and list to look for missing mandatory
labels.
In OCaml 5, Array.map on more than 256 elements forces a minor
collection, which stops every domain. On a 552 module React app this
happened about 2,800 times per build, 87% of all minor collections,
and was most of the extra CPU time a build spends on 7 domains
compared to 1.
The label array is now checked in place, and the missing label search
is skipped when every label is optional. Records with a required label,
like most component props, take the old path. The output is unchanged.
Review: Why does a 1 domain build barely change? Without other domains
waiting at each forced collection, the copy costs about 55 us per
element. The gain comes from the collections no longer stopping the
other domains.
Signed-off-by: Jono Prest <jjprest@gmail.com>
Why:
Translating a record literal still built an array of (label, written
value) pairs over every label, and a second array of (runtime name,
optional) pairs for its shape. For a record with more than 256 labels,
such as a JsxDOM.domProps literal, each of these forces a minor
collection in OCaml 5, which stops every domain.
fields_by_position now returns a list built in position order, and the
shape array is filled in place. Field expressions are still translated
left to right, so the output is unchanged.
Signed-off-by: Jono Prest <jjprest@gmail.com>
d4b317a to
5578f1e
Compare
Sure, done. It seemed like the script would just skip if it was manually added. I won't add in future 🙏🏼 |
JsxDOM.domPropshas 591 optional fields, and every lowercase JSX element paid for all of them:jsx_props_ofcopied every label into a new array just to check whether the record compiles to an array.The label array is now checked in place, and the missing label search is skipped when every label is optional. Records with a required label take the old path. Output is unchanged.
The copy mattered more than its own cost. In OCaml 5,
Array.mapover more than 256 elements forces a minor collection, which stops every domain. On a 552 module React app that happened about 2,800 times per clean build (87% of all minor collections), and it was most of the extra CPU a build spends on 7 domains compared to 1.Clean build of that app, 8 vCPU Linux VM, median of 5 interleaved runs:
Projects without JSX don't change. 300
<div>s in one module now translate as fast as 300 plain function calls (23 ms to 7 ms).Testing:
large_optional_record_test.res(large records with optional,@asand mutable fields, spreads, all-optional records, host JSX with spreads and nesting) and a super_errors fixture for missing labels on a partly optional record. Both match master's output..cmi,.cmj,.astand.cmtare byte identical to master across three production codebases and all their dependencies.make testandmake test-rewatchpass.