Repository navigation
perf(runtime): matching ANode views the block instead of copying it (draft) - #2019
Draft
nicolas-abril wants to merge 1 commit into
Draft
nicolas-abril wants to merge 1 commit into
nicolas-abril wants to merge 1 commit into
Conversation
blk_half returns a view on the host. Freed views merge through midpoint bits and the last one frees the root, so splits no longer leak. Large blocks are aligned to their size for that, and a piece over 16x smaller than its root is copied so a slice can't pin a large block unbounded. comp.ts is over its ttok cap: this is a draft. Refs #1991 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Refs #1991. A draft to look at, not ready to merge:
comp.tsis 713 tokens over its cap, sogates/repo.tsfails, and no perf bench uses array splits yet. This doesn't fix #1991 either; see the numbers below.Matching
ANodecopies both halves today. Views were removed in64adb37dbbecause a block changed size class on every split and leaked (#804). This brings them back on the host and merges the pieces when they're freed, so nothing leaks. The device still copies.How it works
blk_halfreturns a view of the same block. Its aux has bit 5 set and the root block's span in bits 6-10.VIEW_BITS). The second sibling to die climbs a level, and the last one frees the root. This is why large blocks must be aligned to their own size.heap_alloc_misstakes only the gap it needs, with a CAS on the bump pointer. Only large host blocks use the CAS. Using it on every miss made GPU time much worse (merkle3.16x).blk_halfis forced inline and its copy path moved out toblk_part. Otherwise clang stops inlining it and loses the constantarrandhi.Results
All local on an ARM Mac, one thread, best of 3.
mainis017f83fd, which differs from this branch's base only inbend.ts.Array.to_listArray.getloopArray<U32>by matching, 1600 timesmap), 400 timesbfspeak memory, 8 threadsOn the #1991 repro
Array.to_listgets about 31% faster but still takes 2.8x the time and 4.2x the instructions of theArray.getloop, so a flat walk is still the direct fix for that issue.Gates
gates/test.ts: 1819/1819 on this branch. It can't see leaks: the old leaking views passed it too. No test is added here.gates/repo.ts: fails,bend2/comp.ts: 66713 > 66000 ttok.gates/perf.ts, 5 rounds interleaved with main, run on017f83fd: CPU time 1.000-1.003x, GPU time 0.995x, memory within 0.2%, compile time 1.035x. It passed 124/124 three times and 123/124 twice, against main's five clean passes. The miss ismerklecompile at about 1.16x against the 1.15x limit, and main reaches 1.15x there too.Known costs
tree-radixgoes from 0.48 s to 0.68 s, not yet explained; it still passes its pin. Without it the compile geomean is about 1.015x.MAP_NORESERVEand aborts if the mapping fails. This has only run on macOS, so a Linux box with strict overcommit is a real question.🤖 Generated with Claude Code