Repository navigation
A call into a tree recursion runs the callee's returning arms itself and jumps straight to its continuation - #2177
Closed
nicolas-abril wants to merge 8 commits into
Closed
nicolas-abril wants to merge 8 commits into
nicolas-abril wants to merge 8 commits into
Conversation
A segment that reaches no fork tested seq before each frame it pushed and before each call, and carried the task path it never takes: FID_ENTER and FID_EXIT set seq for a fork-free task, and a forking segment hands a fork-free callee to a task of its own. WL_SEQ(F) is seq, or on the host true for a fork-free segment, so clang drops the test, the task path and the frame the path's calls forced on every entry. The one such segment that ran with seq clear is a closure body entered through a Clo~apply that may fork; it now keeps its frames on the stack above the task's frame, as a fork-free task does. symreg -15.8% instructions, queens -6.3%, lexer -2.8% (one thread, M4). Co-Authored-By: Claude Fable 5.2 <[email protected]>
A non-tail call pushes a frame and jumps to its callee; when the callee's match takes an arm that returns at once, the callee pops the frame's id and jumps back through the segment table. In a tree recursion that is at least half of the calls. The call now carries the callee's returning arms: after the frame is pushed and the arguments are in the registers, an arm that neither calls nor jumps runs in place and jumps straight to the continuation the frame names. Any other arm falls through to the call as before. segs_base copies the arms from the callee's emitted entry segment, so they run the code the callee would have run on the same registers. Only for a callee that calls itself twice on one path, on the host, where the frame is on the stack. On top of the fork-free sequential path, one thread, M4: symreg -4.5% instructions and 12.43G to 8.18G cycles (medians of a 16-position sweep; its C twin runs 9.01G); fib(42) 2.74G to 2.03G cycles, tak 9.75G to 6.11G. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 16, 2026
…s too seg_base walks the callee's entry as blocks: a test below the entry chain is copied with its returning arms when the lines before it only name words (the callee runs them again when no arm answers). An arm that drops a subterm stays in the callee: the call to term_drop gave the segment it was copied to a C frame on every entry. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Where a call gets its callee's returning arms, the store of the continuation's id moves below them: an arm that answers jumps to the continuation with the frame as a return would leave it. Not in the callee's own entry, where the call closes a loop that clang then vectorises (tak ran 5.7% more cycles), and a call that gets no arms is emitted as before. Co-Authored-By: Claude Fable 5.2 <[email protected]>
On bendlang#2177's call-site arms: when the continuation pops exactly the frame of the call, pushes none and is at most 48 lines, the copied arms run inside a do/while(0) block, an answering arm leaves it with a flag set, and a copy of the continuation runs there with its frame reads taken from the caller's words. The frame push moves below the arms, so it runs only when no arm answers. Before, an answered call stored its frame, jumped to the continuation and read it back. The continuation pushing no frame is from symreg: copying eval's k1, which pushes the second call's frame, into eval cost 5% instructions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A call into another def runs its own task path, when not sequential, between its frame push and the arms, and that task reads the WL_CONT the push's task branch sets. Moving the whole push block below the arms gave the call the previous continuation at 8 threads (fork_ctor_build and mach_scan_sibling printed wrong numbers and leaked). Only the sequential push moves now. The test adds calls under parallel lets, which print 2586831047 for 772016070 on the previous commit at 8 threads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
As for bendlang#2177's arms: a continuation copied to the call site that calls a spin gives the spin a second call site, and clang stops inlining it. cfold's cfold_k3 put spin_cfold_add and spin_cfold_mul out of line (+5% instructions); tak and deriv lose their small gains with the rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 22, 2026
…e answers at once runs the continuation in place No conflict. The three new commits (1dea074, 1dca6d1, c9575eb) rewrite segs_base's text of an answered call; segs_fuse (with f67950b's key) runs on the segments, not on this text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 22, 2026
… non-tail call that does not read it Conflict in comp.ts, emit_body's choice of the next form (bendlang#2217 against bendlang#2162): bendlang#2162 tries emit_deep on a statement's call before anf, bendlang#2217 tries let_sink on a let first. They apply to disjoint heads (emit_deep only to a call, let_sink only to a let), so both stay: let_sink first, then bendlang#2162's emit_deep-or-anf as before. let_sink only reorders total U32 lets past a frame-pushing call; acc_def (bendlang#2175), def_fix (bendlang#2180) and bendlang#2177's call-site returns rewrite defs before emission and see the lets as written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 22, 2026
mix_sink_calls: bendlang#2217's U32 lets that sink below a non-tail call, in a tree recursion whose returning arms run at the call (bendlang#2177), in sum loops of two and three self calls and one whose arm answers 0 (bendlang#2175), next to a fixed call (bendlang#2180), a let the call reads (stays), and a parallel call. mix_reform_slots: trees in an Array's slots (bendlang#2135: read borrowed, taken and written back) walked by a selector-first lookup and insert (bendlang#2211), split by colour and re-formed (bendlang#2207), lent to a flat def, with the node's U32, Bool and colour in one word (bendlang#2218), in @unsafe helper cycles. Both print main's numbers on C at 1 and 8 threads and on JS. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 22, 2026
…n words The arms copied above a call wrote their answer to r0.., which the path where no arm answers still jumps with: clang merged the two into a select before every miss (pascal's binom_k1: three more instructions per call that the base case does not answer). The answer now goes to wb_r words. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 23, 2026
…ation takes the callee's answer in its own words Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 23, 2026
…, bendlang#2177 and bendlang#2207 Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # bend2/comp.ts
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 23, 2026
…, bendlang#2177 and bendlang#2207 Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 23, 2026
…, bendlang#2177 and bendlang#2207 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 24, 2026
Closed
Draft
Collaborator
Author
|
Moved to nicolas-abril#20, which keeps it saved off the main queue until it can be accepted. |
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
…call's frame is pushed at the call Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
…s frame push stays at the call on the device Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
…s frame push stays at the call on the device Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
…s frame push stays at the call on the device Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
…s frame push stays at the call on the device Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
…s frame push stays at the call on the device Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
…ain 3d5bf43; bendlang#2177's frame push stays at the call on the device) Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
comp.tsis 67,709 ttok, 1,709 over the 66,000 cap (main is 65,966; #2176, which this stacks on, is 66,000; the first commit here 66,774, arms under nested tests +205, the frame id's move +212, the continuation run in place +518), sorepo-gatefails until that is settled. Two commits were added on 2026-11-16 and three on 2026-11-21; each round has its own section below, and the sections before them describe the first commit as it was measured. Measured on one Mac (M4), not on the cluster: thetestandperfgates have not been run. Stacks on #2176: the first commit here is that PR.2026-11-24, fix (
4a9436ea; +196 ttok, 68,000): on the device a call's frame is pushed at the call. The move of a call's frame push (or its id store) below the callee's arguments, made so the host can run the answering arms first, also applied in segments the GPU runs, where those arms are!DEVICEand the move only kept the frame's words and the arguments live at once. In a device segment the push now stays at the call under#if DEVICEand the moved one is#if !DEVICE. Host text unchanged: byte-identical afterunifdef -DDEVICE=0on all 1,032 tests and 244 bend-benchmarks programs (4 tests and 9 programs change, device-only), native lane statuses equal. GPU (Metal, M4,--gpu on, median of 5) on this branch: respelled queens r3 1.993 s to 1.626 s (0.82), r2 2.175 to 2.093 (0.96), runtimequeens2.983 to 2.835 (0.95); the other 19 GPU programs level (0.98-1.02;tree-bitonic1.669/1.683 over 10 runs); all 22 and the 46!tests print expected at--gpu onandoff. Onopt/integrationit takes r3 from 1.96 s back to 1.62 s (main 1.60).2026-11-23, fix (
7beca704; +95 ttok, 67,804): an early continuation takes the callee's answer in its own words. The arms copied above a call wrote their answer tor0, which the path where no arm answers still jumps with: clang merged the two into a select before every miss. The answer now goes towb_rwords.pascal(bend-par) 3.685G / 0.624G to 3.438G / 0.566G (base 3.212G / 0.581G: fewer cycles than the base now, at 7% more instructions, the probes that miss);pascal2,553M / 433M to 2,305M / 418M;coinscycles 124M to 104M;queens61.87G / 19.68G to 60.06G / 18.87G;tak,hanoi,symreg,tree-matmulas before.What it does
A non-tail call pushes a frame that ends in the id of its continuation and jumps to its callee. When the callee is at a leaf of the recursion, it tests its argument, computes a word, pops the id and jumps back through the segment table. In a tree recursion that is at least half of all calls:
evalinsymregwalks 63 nodes a tree and 32 of them areVarorLit.The call now runs the callee's returning arms itself. After the frame is pushed and the arguments are in the registers, the caller tests them as the callee would; an arm that returns at once runs in place and jumps straight to the continuation the frame names (
WL_POPN(1); WL_JMP(FID_k), where the callee hadWL_RETN). Any other arm falls through to the call, unchanged.emit_forkleaves a//base callee continuationline at the call; once every unit is final,segs_basereplaces it with the callee's parameter reads and the leading chain of its entry segment. The code that runs is the code the callee would have run, on the same registers, so ownership, layouts and frees are the callee's own.WL_RETNand has no other jump, push, loop exit or return. An arm that calls a spin is left out (clang inlines a spin while it has one call site: with such arms copied,kmeansran 1.9% andraytrace3.1% more instructions). An arm of 8 lines or more is left out. The other arms keep their tests with empty bodies, so the chain reads as in the callee.term_calls), the shape whose calls mostly end at once. Without this rule a recursion down a list got the test too, once per element for one hit at the end, andlexerlost 3.1% of its cycles (8.09G to 8.34G, medians of two 16-position sweeps that do not overlap) for no instructions.WL_SEQ, or always after a fork's sequential path). The device compiles the block away.Results
One M4, GPU off, one thread unless said. Instructions retired and cycles from
/usr/bin/time -l, builds run in turn, minimum of 3 to 5 runs. "#2176" is the commit this stacks on.symreginstructionssymregcycles (one placement)symregwall, 8 threadssymregcycles on an E-coresymreggoes from 1.37x behind its twin to ahead of it on a P-core (7.8G to 8.4G cycles across code positions, below, against the twin's 9.01G, which was not swept); on an E-core it is still 1.19x behind.Placement: the gain is mostly cycles, so the three builds were swept over 16 code positions (nops at the head of
work_loop, 4 bytes a step), 3 interleaved rounds, the minimum per position:The ranges do not overlap: the slowest position of this build is 3.8G cycles under the fastest of main. Position by position the ratio runs from 1.47x to 1.67x, median 1.55x. Placement alone moves this build by about 8%.
Counters (Instruments' CPU Counters, whole run):
ret)Half of the returns are gone, which is the 32 leaves in 63.
symregwas never short of prediction (0.02 mispredictions a node) or of cache (no misses): over twelve variants of the bench its cycles follow taken branches (R² 0.95) and not instructions (R² 0.23).Three small recursive kernels (scaled copies of the
fib,hanoiandtakports in koru-benchmarks' osprey-compute-kernels), instructions / cycles at one placement:fib(42)hanoi(29)tak(38, 19, 9)The rest of the suite, against #2176:
merkle-0.03% instructions,tree-bitonic-0.01%,tree-matmul-0.17%,tree-radix+0.04%, cycles within the noise; the other 12 emit the same C.queensis not reached:solve's returning arms are nested under an inner test, not arms of its entry chain.Elsewhere: 52 tests emit different C from #2176.
demos/pure_hvm5_mini's C grows 3.2% (72 arms at 42 calls),demos/proof_typed_eval's 7.4% (20 arms at 13 calls),pure_par_sort's 1.3% andpure_par_sum's 0.4%;app_slash_boss_3dand the other 10 demos have no such call. Emitting a demo's C took the same time in single runs (0.1 s to 1.4 s each).Added 2026-11-16: arms under nested tests, and the frame's id
Two commits on top of the one described above (
9b1dc6ec,74a1c357). Everything in this section is measured against that first commit ("#2177 as it stood",3394908c), on the same M4, GPU off, one thread.What changed
seg_basenow walks the callee's entry as nested blocks instead of its leading chain only: a test below the entry chain is copied with its returning arms. The lines between two tests run a second time in the callee when no arm answers, so a nested test is copied only when those lines just name words (a declaration whose value calls nothing butterm_loc,term_aux,term_peekorU32_BIN); a line that takes a node apart (ctr_take), frees, allocates or calls a spin keeps everything below it in the callee.term_sink). The drop is a call toterm_dropout of line, and it gave the segment the arm was copied to a C frame on every entry (warp_k1intree-bitonicgainedstp x29, x30): with such arms copied,tree-bitonicran 10.2% andtree-radix3.7% more instructions. This also takes such arms away from the entry chain, where the first commit copied them; no bench or kernel had one.WL_JMP(k)where the first commit hadWL_POPN(1); WL_JMP(k)). Not in the callee's own entry segment: there the call closes a loop, and with the store after the test clang vectorises the loop's frame pushes (st4.2dintak, which then ran 5.7% more cycles at every placement for 4.8% fewer instructions). A call that gets no arms is emitted exactly as before.Results against #2177 as it stood
Instructions retired, and cycles over 16 code positions (3 interleaved rounds, the least per position; least / median / most, in G). Another agent was benchmarking on the machine during these sweeps.
tree-matmulqueenstree-radixtree-bitonicsymregmerkleCounters over the whole run (one run each):
tree-matmul4.72G to 4.13G taken branches and 1.889G to 0.247G indirect ones (87% of its returns through the table are gone);queens6.54G to 4.52G taken and 0.857G to 0.551G indirect. Mispredictions barely move (19.7M to 16.9M, 574M to 559M).symregdiffers in 9 of its 46 segments (the continuations ofevalandesize, andfloop): only the frame id's store moved;eval's entry is textually the same.The koru kernels, scaled as above (
pascal30/15,coins1200,binarytrees8000 trees,ackermann3/12,exprtree600 trees):tak(38, 19, 9)fib(42)hanoi(29)pascalcoinsbinarytreesackermannexprtreepascalis the cost:binom's frequent returning arm (n == 0, 42% of its calls) calls two spins and stays in the callee, so the copied tests answer only the rare one (k == 0, 8% of calls) and the rest run them twice. It runs 14.5% more instructions for 3% to 7% fewer cycles.Per widening
9b1dc6ec)queens-15.5%,tree-matmul-19.1%,tree-bitonic-0.1%,tree-radix+1.0%;coins-21.5%,pascal+12.3%tree-matmul+13.9%,queens+4.3%74a1c357)tree-matmul-19.1% to -25.4%,tree-radix+1.0% to -0.3%,tak-9.5%,coins-21.5% to -24.2%,fib-2.0%,binarytrees-1.0%symreg-2.8% (cycles 0.915x to 1.016x, overlapping)tak+5.7% cycles at every position: clang vectorises the pushespascal-8.3% where it is now +14.5%,exprtree-6.9%,tree-bitonic-2.2%raytrace+3.1%,kmeans+2.0%, as first measuredkmeans-0.4% (szip), nothing elsetree-bitonic+10.2%,tree-radix+3.7%lexer's 591M non-tail calls 11% end at once (gen3%,ident22%,num29%);digitsum18%,collatz1%lexerloss standstree-bitonic3.9%,queens0.8%)How the calls of each bench end was counted with a profiling build (every non-tail call tagged with its site, every return with its arm). Of the non-tail calls, those ending at once in an arm under a nested test:
tree-matmul86% of 1.91G,queens36% of 857M,tree-radix40% of 238M,coins50%; in an arm that calls a spin:tree-bitonic45% of 2.34G,pascal42%,raytrace50% andmandelbrot49% (where the arm is the whole leaf's work).With the current #2175 (
opt/nat-accumulateat2707077e, this branch patched on):fib,pascalandbinarytreesare as with #2177 as it stood (same instructions for the first two, -0.4% for the third, cycles in the same ranges).coinsis slightly worse: 11.62G to 12.00G instructions and 2.33 / 2.42 / 2.65G to 2.50 / 2.59 / 2.87G cycles (overlapping). The additions pay onqueensandtree-matmul, which #2175 does not touch.The two known problems
coins(A call into a tree recursion runs the callee's returning arms itself and jumps straight to its continuation #2177 alone 9% slower than main at 13.7% fewer instructions): two things, both seen in the counters. The first commit's block atways' own first call answers almost never (78 of 14.9M calls: that call walksamountdown like a list), and with it clang laysways' entry out so that every entry takes one more branch: 2.00G to 2.80G taken branches for the same 3.60G branches and 0.80G indirect ones. Under that, the kernel is bound by a store and a reload: each level pushes the first call's result and pops it to add, and the cycles stay between 3.9G and 4.4G from 17.2G down to 11.2G instructions. With the continuation's add run at the answering site by hand, the reload goes and the cycles fall from 4.38G to 2.87G. That is what A def whose tail adds calls to itself carries the sum in a parameter: any spelling of the add, U32, and two or more calls #2175 removes for sums; nested arms takecoins' taken branches to 1.60G but not its cycles.pascal(with A fork-free segment takes its sequential path on the host without testing seq #2176, A def whose tail adds calls to itself carries the sum in a parameter: any spelling of the add, U32, and two or more calls #2175'sbinom~accruns 8% more cycles at 12.8% fewer instructions): once A fork-free segment takes its sequential path on the host without testing seq #2176 removes theseqtest from the loop that descendsn, clang vectorises its frame pushes (st3.2d, eight frames a turn; SIMD instructions 0.0001G to 0.079G, taken branches and mispredictions unchanged). With the pushes kept scalar by hand the build is back inside A def whose tail adds calls to itself carries the sum in a parameter: any spelling of the add, U32, and two or more calls #2175's range (3.13 / 3.19 / 3.29G against 2.98 / 3.12 / 3.29G; vectorised 3.33 / 3.38 / 3.45G) at 19% fewer instructions. The same barrier makeshanoi2% to 19% andbinarytrees4% to 12% slower at every position, so no rule is emitted for it.Checks for the additions
All local, against #2177 as it stood (
3394908c):#|lines on both, 21 differ from them and 1 times out on both; no status differs. The new test is the 886th.tree-matmul+14.6%,pure_hvm5_mini+5.1%,queens+4.4%. The JS of all 943 is byte-identical. Emitting all of them took 214.1 s before and 213.5 s now.-DBEND_POISON, at the default thread count and at 8.!call print the same with--gpu onand--gpu off, before and now (the arms are compiled away on the device; the frame id's move is in the device code of 3 of them,fork_leaf_handoff,gpu_markand the new test).tests/run/call_returns_nested.bend: two trees matched together with arms that free and arms that reuse their node, three tests deep, a Bool then two Nats (the shape ofcoins), shared trees read by two walks, a word test under a tag test, one def called by an owner and by a reader, forks, a!call, a comb 3000 deep; and the shapes that must stay: a nested arm that drops a subtree, and one behind lines that take a node apart, also on a tree that a reader and a picker share. Its lines are main's on the C lane (1 and 8 threads), under bun and underbend file.bend. A counting build takes 9,073 returns under a nested test and 20,271 on the entry chain, at 1 and at 8 threads.!call given arms, and arms run while the frame is in a task (seqclear). No test reaches a copied arm withseqclear; that condition is the first commit's.Verdicts
queensandtree-matmul. Alone it lefttree-radix1.0% up in instructions (its cycles overlap); with the frame id's move no bench of the suite runs more instructions.symregthat I could not separate from placement and a loss ontakthat I could.pascal's +14.5% into about -8%, but as it stands it repeats thekmeansandraytracelosses.coinsfrom 4.38G to 2.87G cycles andfibfrom 2.20G to 2.06G (one position each,fib's for 2.4% more instructions); it copies continuation text into every arm.Not covered by the additions
tsc, as above.queens, not intree-radix'merge, which is where the +1.0% was), and whether it vectorises a loop of frame pushes (pascal,tak).Added 2026-11-21: an answered call runs its continuation in place
When a call's callee answers at once through the copied arms, the call still stored its frame, jumped to the continuation and read the frame back. Now, when the continuation pops exactly that call's frame, pushes none, and is at most 48 lines, the copied arms run inside a block that an answering arm leaves with a flag set, and a copy of the continuation runs there with its frame reads taken from the caller's words. The sequential frame push moves below the arms, so it runs only when no arm answers. First built as branch
opt/queens-early(kept), stacked on this PR.Two restrictions, each from a measurement:
symreg'sevalcontinuation, which pushes the second call's frame, intoevalcost 5% instructions.cfoldput two spins out of line (+5% instructions);takandderivlose their small gains with the rule.Instructions against this PR's previous head (74a1c35), one thread, GPU off, M4:
queenssymreghanoi(koru)coins(koru)fib(koru)binarytrees(koru)cfold,deriv,pascalEvery other bench of the suite is within noise.
Bug found by the checks and fixed (1dca6d1): a call into another def runs its own task path between its frame push and the arms when not sequential, and that path reads the continuation the push's task branch set. Moving the whole push block below the arms gave such a call the previous continuation at 8 threads (
tests/run/fork_ctor_buildandmach_scan_siblingprinted wrong numbers and leaked). Only the sequential push moves now; the new test adds calls under parallel lets, which printed 2586831047 for 772016070 on the faulty commit at 8 threads.Checks, against the previous head: all 60 changed tests, benches, demos and kernels give the same output as before on every lane, with the same live-word counts under poisoned frees at 1 and 8 threads; the four Perceus
rbtreeports checked on C and with the memory check (0 live words). Every deliberately wrong version of the change is caught by the new test, the 8-thread bug included. Not run: the cluster gates, CUDA, Linux, x86; JS and the interpreter on therbtreeports (too heavy here).Checks of the first commit
All local, against main
f0cf0a7cand against #2176:#|lines on main and here, 21 differ from them and 1 times out on both, no status differs.-DBEND_POISONand a count of live heap words at exit: the 51 of those 52 tests that build give the same output, exit code and count as main. An earlier version of this branch, which answered the calls of every callee and not only of tree-shaped ones (so a superset of these calls), gave the same on all 905 tests that build.tests/run/call_returns.bend: a returning arm that frees the node it owns, one that allocates, one that drops another owned parameter, a three-word result, a Nat match two levels deep, a returning arm written after the calling one, a shared tree read by two walks, a forking def and forks over fork-free ones; and the shapes that must stay as they were (a recursion down a list, two defs that call each other). Its lines are main's; it prints them on the C lane (1 and 8 threads), under bun and underbend file.bend.compile_bookis the C emitter).!call print the same with--gpu onon main and here; the block is under!DEVICE, so the device compiles it away.repo.tsfails only on the ttok cap.Not covered
tscwas not run.Cost
+774 ttok over #2176 for the first commit, +417 for the two added (+1,225 over main).
Where this came from
symreg's gap to its twin was put down to branch prediction. The counters say otherwise: 0.044G mispredictions in 12.4G cycles. What the cycles follow is taken branches, about 1.2 cycles each, and a leaf reached by a call costs four or five of them (the jump in, the tag tests, the return through the table). Answering the leaf at the call leaves one or two. Real C calls were bounded earlier at 1.14x forsymreg; this gives 1.55x inside the segment machinery.🤖 Generated with Claude Code