Repository navigation
JIT: fix quadratic code size at exits - #6342
Merged
Merged
Conversation
…ment block Every exit and unwind site stored its own live slots into the exit routine's argument block. In straight-line code the live slots grow with the function, so the stores were quadratic in its length: 88% of the IR of the test transcript's largest modules. A site with more than four live slots now branches to blocks shared with the function's other sites, one per slot on top of each distinct set of lower live slots. Each slot has a fixed place in the block, which the routine reads when the descriptor's new flag bit is set. UNISON_JIT_EXITS=call keeps every site storing its own.
SharedKey holds Pairs and Deques, liveSlots gives a Deque, and joinCall builds the descriptor from Deques. The generated IR is unchanged.
Member
Author
|
GitHub actions had an outage again, so this died in the merge queue. Reenqueing... |
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.
When a native-compiled function exits back to the interpreter midway through its execution, it has to write any still-live variables back to the Unison stack. Previously that was inlined at each exit site, at a code size cost proportional to the number of variables being written, leading to a quadratic amount of code in some cases.
Now it's a linear amount of code for straight-line functions, solved by having these write backs to the stack share code in the obvious way. This change only kicks in for exits with > 4 live variables. Below that threshold it still writes them back inline, as before.
Results:
jit-tests.mdunder the stress combination (thestress-allandno-irhelpersrows that dominate the jit jobs): 222 s down to 99 s. Undereager: 99 s down to 58 s.jit-benchmarks.mdis within 1% overall. The slowest row is 7% slower ("Loop state: a record updated each round"), and five more are 4-5% slower.The second commit is a cleanup with no change to the generated code: the keys and lists on this path become strict pairs and
Deques.Tested with the whole JIT test matrix (19 rows) and, on the debug RTS, the
eager,on-t1,stress-allandinstall-allrows plusjit-benchmarks.mdunder-DS. The numbers are inbenchmarks/2026-11-11-shared-write-back.md, and the design is in the Write-back section ofdesign.md.