Skip to content

Reuse copy buffers in OCaml rewatch - #8869

Draft
cknitt wants to merge 1 commit into
masterfrom
reuse-copy-buffers
Draft

cknitt wants to merge 1 commit into
masterfrom
reuse-copy-buffers

Conversation

@cknitt

@cknitt cknitt commented Oct 15, 2026

Copy link
Copy Markdown
Member

OCaml rewatch allocated a fresh 64 KiB buffer for every file it published (.cmi, .cmj, .cmt, ASTs, sources), and two more for every same-sized .cmi it compared. An allocation profile (Gc.Memprof) of a clean tests/tests build showed these buffers as the largest single source of allocation: 17.5% of all words. Blocks that size go straight to the major heap, so they also drive major-GC work, which with several domains stops all of them.

Each domain now keeps one copy buffer and one comparison buffer and reuses them.

Clean builds of tests/tests without string_unicode_test (see #8866), idle Linux VM with 10 cores, median of 7 interleaved runs:

Before After
Allocated words 241M 198.5M (−18%)
Wall, 1 domain 1.312 s 1.246 s (−5%)
Wall, 8 domains 0.422 s 0.370 s (−12%)

🤖 Generated with Claude Code

Fresh 64 KiB buffers per copied file were the largest single source of
allocation in a build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WZbCuRQ1Tn31bnKzLj5e72
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the reuse-copy-buffers branch from dd71607 to d9d9d32 Compare October 15, 2026 18:42
@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8869

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8869

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8869

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8869

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8869

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8869

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8869

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8869

commit: d9d9d32

@github-actions

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant