Conversation
The shared-segment rule (Q60) offered one fixed grid, the gcd of every window's lookback and offset. It now offers two segmentations, each as its own Stage 1 variant, and Stage 3's cost decides: - split only at the windows' own boundaries (fewest segments); for Example 3a four segments, the oldest two years wide; - the even gcd grid (3a: five 1-year segments), when it differs. WindowForm::Segments carries the grid unit and a bitmask of where each segment ends, so a target's segments may differ in width; tumbling_state and the coverage proof take the widths. Sharing::WindowSegments carries the number of distinct segments, labeled "· shared segments ×4" / "×5". Each segment is still sized for the group's strictest reader. Stage 2 does not maintain a merge of panes of different widths at ingestion time or keep it: it is no stream of panes. So in 4a only the even grid has an ingestion-time option. Example 3a and 4a select the four boundary segments: they build the same rows as the five 1-year ones and merge fewer states (3a: 18,104.0039 vs 18,104.0044 per second). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
stack/windows-3-pricing
branch
from
October 5, 2026 06:21
44291c9 to
9cf2956
Compare
zzylol
force-pushed
the
stack/windows-4-segment-grid
branch
from
October 5, 2026 06:21
8d5052f to
1397f2e
Compare
This was referenced Oct 5, 2026
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.
Stack: #574 → #620 → #618 → #621 → #627 → #625 → #628 → #632 → #634 → #616 → #617 → #622 → #624 → #629 → #630 → #631 → #633 → #635 → #636 → #637
Problem
The shared-segment rule from #628 (
share_window_segments, logical-optimizer Pass 2) offered only one grid: even segments whose width is the gcd of every window's lookback and offset. The planner never compared that grid with alternatives. For Example 3a, splitting only at the windows' own boundaries needs 4 segments instead of 5.Changes (Q67)
· shared segments ×4and· shared segments ×5. A target's label lists uneven widths, for exampleKll · 365d+365d+365d+730d segments. An even grid keeps the old label,365d segments.WindowForm::Segments { unit_ms, ends }: the grid unit plus a bitmask of where each segment ends, soWindowFormstaysCopy.WindowForm::widthsgives the pane widths.tumbling_stateand the W2 coverage proof (panes_cover_window) now take widths, so panes no longer need equal widths.Sharing::WindowSegments { segments }carries the number of distinct segments, which also keeps the two variants distinct.materialization.rs): aSummaryMergeover panes of different widths is not a stream of panes, because no pane is an older pane shifted back. Its chain is therefore neither maintained at ingestion time nor kept. In 4a only the even grid has an ingestion-time option.pattern_a_shares_four_boundary_or_five_one_year_segments(both forms, their ends masks and labels; 4 or 5 builds and 5 merges after composition),identical_segmentations_are_offered_once(new),stage1_a_shared_segments_serve_all_five(both candidates; each query's segments sum to its range),stage3_a_selects_the_cheaper_segment_grid(new),stage2_a_segments_are_built_once_for_all_consumers(4 and 5 segments, once and monthly), and theexample4a_*devtools test (489 plans; only×5is maintained at ingestion time).tools/dag-viewer/examples.json: the 3a and 4a stories are updated.planner-layering-example1.jsonis unchanged (verified by regenerating it).Costs of each segmentation (after #632's pricing)
The two grids cost almost the same. Under #632's pricing each row of the scan lands in exactly one segment, so the range and build work is the same for both. The ×4 grid wins only because its merges read fewer states: 4+1+1+1+2 instead of 5+1+1+1+3. Shared input costs 25,112 (3a) and 34.878 (4a).
Test plan
cargo fmt --all --check,cargo clippy --workspace --all-targets -D warningscargo test --workspace: 1692 passed, 0 failed, 13 ignored (after the rebase on main d4869a7; was 1681 passed, 13 ignored)tools/dag-viewer:python3 -m unittest test_viewer: 25 OKstage_pipelinefor all six examples. Only the 3a and 4a selections change (to×4).Stacked on #632 (
stack/windows-3-pricing).🤖 Generated with Claude Code