Repository navigation
ZJIT: Find caller-saved survivors without scanning every interval per CCall - #19681
Open
thomasklemm wants to merge 1 commit into
Open
thomasklemm wants to merge 1 commit into
thomasklemm wants to merge 1 commit into
Conversation
thomasklemm
force-pushed
the
thomasklemm/zjit-caller-saved-regs-stopgap
branch
from
November 5, 2026 00:27
dea97c3 to
bb2c44d
Compare
thomasklemm
added a commit
to thomasklemm/lowrail
that referenced
this pull request
Nov 5, 2026
Move ruby-bench #569-#572 from Merged to Open (ready), drop the duplicate with_advisory_lock#150 entry, add ruby/date#199 and the closed ferrum#697, mark ransack#1795 and tzinfo#175 ready, refresh heads (#59614, #59668, ruby-bench#568, ruby/ruby#19681, tzinfo#171), add missing merge dates, and record the 2026-11-05 open counts. RA1 item synced to ready.
thomasklemm
force-pushed
the
thomasklemm/zjit-caller-saved-regs-stopgap
branch
2 times, most recently
from
November 15, 2026 11:20
5dedcb0 to
2e5b708
Compare
… CCall handle_caller_saved_regs() filtered all intervals for each CCall, which is O(CCalls x intervals) and showed up in compile-time profiles of large methods. Map each register interval's live ranges onto the sorted CCall positions once, with a binary search per range, into one flat table of covering intervals per position. Each CCall then reads its slice of that table into reused survivor buffers, giving the same survivors in the same VRegId order as before. This is a stopgap for Shopify#1065; it does not split intervals.
thomasklemm
force-pushed
the
thomasklemm/zjit-caller-saved-regs-stopgap
branch
from
November 18, 2026 11:52
2e5b708 to
5df7fef
Compare
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.
This change halves the time ZJIT spends compiling one method with 2,000 or 4,000 calls.
handle_caller_saved_regs()filtered every interval at every C call to find the registers live across it, so its cost is the number of C calls times the number of intervals. This PR maps each register interval's live ranges onto the sorted C call positions once, with a binary search per range, into one flat table. Each C call reads its slice of that table; there is no intermediate Vec per C call, and the survivor buffers are reused. Survivors keep the same VRegId order, so the generated code is unchanged.This is a stopgap; it doesn't split intervals.
Fixes Shopify#1065
--zjit-statsat--zjit-call-threshold=2for this script, which calls one method of Ns ^= o.hashcalls three times:N=2000:
N=4000:
code_region_bytesdoesn't change. On railsbench, lobsters and shipit,compile_timemoved by less than run-to-run noise, so I left those diffs out.