Semantic Diff

#9187 Skip copying every props label per JSX element

2 commits

6741bab07e473f7dbec3e56efc6a807dee8eea28..pr-9187

3b95c9eb5 · JonoPrest · Nov 03, 2026, 07:59 UTC

Don't copy every label of a large record per JSX element

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.
5578f1e5b · JonoPrest · Nov 03, 2026, 14:37 UTC

Don't copy every label of a large record literal either

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.