Repository navigation
fix(data_plane): delete each view's windows at its own retention - #859
Merged
Merged
Conversation
zzylol
force-pushed
the
fix/cold-view-pages
branch
from
November 23, 2026 14:33
82174ba to
2feadb0
Compare
zzylol
force-pushed
the
fix/per-view-segment-retention
branch
from
November 23, 2026 14:33
e5a63ca to
fd867e7
Compare
View segments were per refresh group, and a group's segment was deleted only once every view in it was past retention: so at the group's longest retention. On a live run, one group held all the 15 s views: a quantile sketch view read back 1 h, other views 30 min, 5 min and 1 h, and a max view read back 6 h. Each 15-minute segment lived for 6 h, and the sketch view's part, about 107 MB of each 172 MB segment, stayed on disk and in the page cache 5 h past its 1 h retention (5.4 GB of view files). Segments are now per refresh group and retention: a group's views of one retention share a directory group-<g>/retention-<ms>/, and each window's record is written once per retention (its own texts and grids). A view's windows are deleted when every window in a segment of its retention is past that retention of the newest window. Indexing records each view's retention; delete_expired takes the newest window end and applies each retention. A segment written before the split, directly in group-<g>/, is loaded and deleted at the group's longest retention, as before. Chosen over punching holes (fallocate PUNCH_HOLE) in shared segments, which keeps the file sizes and needs per-view extents tracked and page- aligned, and over compaction, which rewrites live data; separate files need no new on-disk structure and keep "a segment is deleted whole". Also fixes delete_expired dropping the rest of a group's sealed list when one unlink failed. A unit test writes a 20 ms and a 1000 ms view of one group and checks that the short view's old segments are gone after its retention while the long view's stay and read back.
…etention; an unlink failure keeps the sealed list Two unit tests for the per-retention split: segments written directly in group-<g>/ before it are indexed, read back, and deleted only past the group's longest retention; and a failed unlink no longer drops the rest of a retention's sealed list, so a later call deletes them.
zzylol
force-pushed
the
fix/per-view-segment-retention
branch
from
November 23, 2026 14:34
fd867e7 to
510b4ae
Compare
zzylol
changed the base branch from
fix/cold-view-pages
to
feat/tiered-view-storage
November 23, 2026 14:34
zzylol
marked this pull request as ready for review
November 23, 2026 14:34
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.
Summary
queue_depthfor q7 (6 h). Each 15-min segment therefore lives for 6 h. Its DDSketch part, about 107 MB of each 172 MB segment, stays on disk and in the page cache 5 h past its 1 h retention, and the view files take 5.4 GB on disk.group-<g>/retention-<ms>/. Each window's record is written once per retention, anddelete_expiredapplies each retention to the newest window end.file_mappedis 0.19 GB instead of 0.54 GB.Review guide
feat/tiered-view-storage(rebased after fix(data_plane): advise view segments behind the newest sealed one cold #858 merged).ViewFiles::append/append_record(how records are split by retention),ViewFiles::delete_expired, and the directory scan inViewFiles::index, all indata_plane/src/persist.rs.GroupFiles→RetentionFilesrename, thefilesmap now keyed by(group, retention_ms), the removal of the per-group retention vector fromengine.rs, the test helpers intests/view_tiering.rsandtests/view_persistence.rsthat now look one directory deeper, and the docs.Behavior: before → after
The asap-demo plan: q1
quantile_over_time(0.99, lat[1h])and q7max by (job) (max_over_time(queue_depth[6h]))are both answered from 15 s chains in refresh group 0.views/group-0/<end>.seg(all views)views/group-0/retention-3675000/<end>.seg(q1's DDSketch, the Counter chains),retention-21675000/(q7),retention-1875000/(q3),retention-375000/(Count)Answers are unchanged: the store drops a view's windows at its retention already. Only the file lifetime changes. This serves the MVP disk and memory comparison.
Interfaces
data_plane/src/persist.rsOn-disk layout:
group-<g>/<end>.segbecomesgroup-<g>/retention-<ms>/<end>.seg. The segment format is unchanged (still version 2). A segment found directly ingroup-<g>/, written before this PR, is loaded and deleted at the group's longest retention, as before.Usage:
data_plane --plan plan.json --view-dir views/.Engine::spawncallsViewFiles::index(&precompute.views()), which records each view's retention including the store margin (q1: 3,675,000 ms; q7: 21,675,000 ms). For each refreshed group-0 window, the persist thread callsappend(0, (start, end), views), which writes four records, one per retention directory. It then callsdelete_expired(0, end), which removes q1's segments whose windows all ended beforeend − 3,675,000and keeps q7's for 21,675,000 ms. In the 105-min run this held the view files at 0.87 GB.Algorithm changes
Segment expiry.
appendwrote one record per window togroup-<g>/, anddelete_expired(g, end − max retention of g)deleted whole segments. After,appendgroups the views byretention_of(view)andappend_recordwrites one record per retention to that retention's active segment, which rolls on its own.delete_expired(g, end)deletes, for each retention r, the sealed segments withmax_end_ms ≤ end − r.Decisions and open questions
Needs reviewer decision: None.
Decided (2026-11-23): one directory per (group, retention), option (a). Rejected: (b)
fallocate(PUNCH_HOLE)inside shared segments, which needs page-aligned per-view extents tracked, keeps apparent file sizes, and makes "a segment is deleted whole" no longer true; (c) compaction, which rewrites live data.Verification
cargo test -p data_plane --lib--test planner_executor_parity--test view_persistence/view_tiering/view_cold_allocations/view_memoryretention-*/cargo clippy -p data_plane --all-targetsNew test
each_view_expires_at_its_own_retention: one group holds a view with 20 ms retention and a view with 1000 ms retention. After windows up to 80, the short view's three sealed segments are deleted, the long view's segments stay, its oldest window reads back the same rows, andbytes()drops.segments_roll_and_expire_wholeis updated to the newdelete_expired(group, newest_end_ms).Added in review:
old_layout_segments_load_and_expire_at_the_longest_retention(segments directly ingroup-<g>/are indexed, read back, kept past the short view's retention and deleted past the group's longest) anda_failed_unlink_keeps_the_sealed_list(with the retention directory read-onlydelete_expiredfails; after restoring it, the next call deletes all four expired segments). Rebased ontofeat/tiered-view-storageafter #858: data_plane lib 53,planner_executor_parity4,view_persistence7,view_tiering9,view_cold_allocations1,view_memory1, all passed.Measured on a spare host (same setup as #858: asap-demo, 10k series, 8 users, 12-core cgroup with a 64 GiB limit, window cache off, 110 min). "Before" is the base branch; "after" is this PR, which includes #858. Values are GB:
memory.currentat minute 105: 2.56 GB before, 1.77 GB with #858 alone, 1.49 GB with this PR. Queries: 28,548 answered OK, no errors. p50 / p99 latency after minute 75: 0.086 / 4.09 s (before: 0.186 / 4.22 s). Before this PR the disk keeps growing until 6 h, so the live demo's 5.4 GB of view files should drop to roughly the 1 h views' share plus the small 6 h and 30 min views. That figure is not measured here; the run was 110 min.Follow-ups