Repository navigation
Count snapshot alias costs with prefix sums (fixes #319) - #346
Merged
Merged
Conversation
20 tasks done
Snapshot selection repeatedly walks per-page postings when aliases overlap, making heavily overlapping cache layouts expensive to select. Each alias is a validated contiguous page range, so prefix sums can count its free backing and pairwise overlap exactly. Replace candidate page vectors and posting lists with free-page and blocked-page prefix sums. Use an excluded-page bitmap and prefix sum for larger greedy witnesses, and reject insufficient candidate sets early. Retain the reference tests and replace the posting-offset helper test with selection over the same large overlap geometry. Preserve minimum-cost selection and lowest-ID ties for one or two rows, and preserve the greedy witness for larger counts, while removing page work proportional to aggregate pair overlaps. No candidate cap is added. In a macOS scratch build with platform shims, 310 scheduler tests and both production-geometry tests passed. Randomized selection matched the reference in 41,910 comparisons. Main exceeded the nested-alias work bound with 5,732,032 page visits; the replacement used 256 for two rows. The production fixture showed no two-row quote-time improvement. On Linux (rebased on main with NVIDIA#354), scheduler:: and server::runtime::phase_tests pass 422 tests. An independent comparison of the compiled select_snapshots from main and from this change matched on 18,054,687 randomized inputs (6.9M feasible), including nested, random and short-window shapes; eight injected mutations were each caught by the change's own comparison test. On a nested shape with 1,986 aliases over 327,680 pages, one two-row selection takes 10.23 s on main and 0.84 ms here; one-row selection takes 14.8 ms and 0.88 ms. On DeepSeek-V4.1-Flash TP4 (4x RTX PRO 6000), 32 cold ~12.7K-token requests start in 28.8 s median (main with NVIDIA#354: 29.0 s), and 10 minutes of the NVIDIA#319 agent load (12 conversations, ~70K shared prefix, 60% cancelled mid-stream) ran 210 requests with no errors and no wedge. Not tested: TLA+, Kani, and the remaining cost of re-selecting after each eviction inside one quote (a follow-up). Design-Signed-Off-By: yatesdr; design-review=ed22
yatesdr
force-pushed
the
fix/helios-exact-snapshot-selection
branch
from
November 18, 2026 22:01
90e5552 to
7a1b5ad
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.
Fixes #319. Part of #335.
#354 removed the planner's per-waiting-request storage simulations, which multiplied the cost of
select_snapshots. It did not change the cost of one call. On nested-alias shapes, which are common under agent traffic with long shared prefixes, one two-row selection takes seconds, and a quote can run several selections. This PR removes that per-call worst case, so #319 stays fixed under heavier shapes than #354 alone handles. It makes each selection exact and cheap: prefix sums over contiguous alias ranges replace per-page postings.The other proposals for #319, and what happened to each idea:
[0, 1, 128]and the cap returns none. A rejected selection makes the quote evict checkpoints it did not need to. This PR keeps the exact result instead, with no cap.Remaining follow-up: a quote still re-selects after each eviction (1+E selections), and each selection is now cheap.