Repository navigation
perf(melange): enlarge the minor heap for source compilation - #17022
Open
anmonteiro wants to merge 1 commit into
Open
anmonteiro wants to merge 1 commit into
anmonteiro wants to merge 1 commit into
Conversation
anmonteiro
marked this pull request as ready for review
November 13, 2026 13:51
Default CMI/CMJ actions to OCAMLRUNPARAM=s=1M when neither OCAMLRUNPARAM nor CAMLRUNPARAM is present, including empty values. Resolve the environment in the compilation directory so env stanzas retain precedence. Leave JavaScript emission and native OCaml actions unchanged. Reuse the runtime-environment coverage from ocaml#16958. Benchmarked with a native wrapper applying settings only to CMI/CMJ actions, keeping Dune and JS emission fixed. Apple M2 Max, 64 GiB, macOS 26.5.2, Melange linked with OCaml 5.5.1, Dune a0288ef. Fresh build directories, cache disabled, warm filesystem cache, release profile, -j 6, six randomized paired blocks per workload. Percentages below are medians of paired changes, not ratios of separate medians. Source CPU Build CPU Wall Peak melc RSS Belt -7.37% -2.22% -2.35% +18.81% Melange stdlib -10.43% -1.84% -2.28% +8.26% Synthetic (8 modules) +0.85% +0.19% +1.26% -1.37% Peak compiler RSS medians increased from 33.4 to 38.9 MiB for Belt and 74.4 to 80.9 MiB for stdlib. Separate process-tree sampling at -j 6 measured about 243 to 286 MiB for Belt; stdlib stayed near 289 MiB. Dev-profile follow-ups showed 9.7-10.6% less source CPU on the real libraries, but small/noisy end-to-end changes. A large synthetic module (-j 1, three pairs) had +1.41% source CPU, +3.17% wall, and -4.35% RSS. Synthetic workloads therefore do not show a consistent speedup. A 512k-word heap helped stdlib less and did not help Belt consistently; 2M increased memory further. GC diagnostics with 1M reduced minor collections from 771 to 288 for Belt and 1490 to 523 for stdlib, with essentially unchanged allocation counts. This is an alternative to ocaml#16955, not an additional speedup: combining s=1M with Xsmall_heap_limit=16777216 increased median source CPU by 1.06%, 2.76%, and 3.57% for Belt, stdlib, and the medium synthetic case relative to that major-GC setting alone. Related native compiler work is in ocaml#16914. All 168 measured/diagnostic builds had identical CMI/CMJ and JavaScript hashes within each workload/profile/batch, equal action counts, and passing Node runtime checks. Validation: dune fmt, @check, @fmt, and the Melange runtest-melange suite pass, including compiler-gc.t. The full @runtest run fails in existing macOS/Nix cases: missing gcc, code signing bytecode scripts, and filesystem-event expectations. These failures also occurred on the unchanged baseline; none of their test files changed here. Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
anmonteiro
force-pushed
the
anmonteiro/melange-minor-heap
branch
from
November 14, 2026 21:13
71f4c54 to
ec08c33
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Default Melange source compilation to a 1M-word minor heap when no runtime settings are provided.
Uses the merged coverage from #16958. Related to #16914 and an alternative to #16955: combining the minor- and major-GC settings did not improve the benchmarks.
01a1d391-6eb8-7990-b66f-fb8a2a36015f