Repository navigation
A native build lets go of the compiler's memory before clang runs, so its peak is the larger of the two, not their sum - #1385
Merged
Conversation
bend x.bend -o x waits on clang with spawnSync while the compiled book's File (every segment's lines, the memo tables, the facts) stays reachable, so the emission's heap sat beside clang for the whole C compile. compile_book now leaves FL as a fresh File once the C is built, and cli_emit collects before cli_build. On AMAGE Eco's reference renderer bend holds 0.80 GiB while clang runs instead of 1.69 GiB, and the build peaks at 1.68 GiB instead of 2.37 GiB. The C and the binary are the same.
This was referenced Oct 7, 2026
Lorenzobattistela
approved these changes
Oct 7, 2026
Iann29
added a commit
to Iann29/bend
that referenced
this pull request
Oct 7, 2026
…d too bendlang#1385 brought main's comp.ts to 63,975 ttok, which put this branch at 64,015. These rewrites take 30 back, with the same output: the File, Scope, Seg and Spine types list several fields per line; term_const, fun_of and intr_of read lit_call's result, h and tld.i as truthiness, since each is an object or an array when present. The branch is at 63,985, and merged with bendlang#1387 (which takes its own share) at 63,989.
Iann29
added a commit
to Iann29/bend
that referenced
this pull request
Oct 7, 2026
…d too bendlang#1385 brought main's comp.ts to 63,975 ttok, which put this branch at 64,017. These rewrites take 38 back, with the same output: js_host moves into js_lib, its one caller, with the js_marshal calls in the same order; six OPERATIONS entries with a short C template take two lines, not four; lay_box, val_box and val_unbox read lay.arms as truthiness, since it is a record when present. The branch is at 63,979, and merged with bendlang#1386 (which takes its own share) at 63,989.
Merged
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.
bend x.bend -o xwrites the C, then waits on clang withspawnSync. All that time the compiled book'sFile(FL: every segment's lines, the memo tables, the facts) stayed reachable, and the waiting process allocates nothing, so nothing collected it: bend's emission heap sat beside clang for the whole C compile.compile_booknow leavesFLas a freshFileonce the C is built, andcli_emitcollects (Bun.gc(true)) beforecli_build. The C and the binary are unchanged.Memory
AMAGE Eco's CPU reference renderer (
Chromi/examples/eco/reference.bendfrom amage-si: 1,759 segments, 4.1 MB of C),bend reference.bend -o ref, RSS sampled every 0.2 s, on a Ryzen 7 5800H (32 GB, Linux) with Bun 1.4.2 and clang 22:With only
Bun.gc(true), bend held 1.47 GiB during clang: most of what it kept wasFL. AddingBun.shrink()after the collection changed nothing measurable.Same output
compile_book's result is untouched: for all 1,668.bendfiles undertests/,demos/andbench/, the emitted.c,.jsand.mjsand the exit status and stderr of every file are the same as main's.gates/test.ts's shard script run locally (Linux, no display, no CUDA), on the previous main (eebc18c): 1579 / 1581 with all three PRs of this work applied, and the same on main: the misses areio_chan_try_late[c] (a timing race on this machine) andio_process_run[interp, js] (its inherited-pipe cases, under the local runner).comp.tsis 63,972 ttok (main: 63,940) andmain.ts10,285 (main: 10,280).tsc -p bend2/packreports the same 12 errors as main, andgates/repo.tspasses, 50 / 50.Found while building AMAGE Eco, a UI toolkit written in Bend 2 (amage-si).