Repository navigation
data-plane: compact, compressed view fragments (format 4) - #866
Merged
Merged
Conversation
zzylol
force-pushed
the
feat/compact-view-segments
branch
from
November 24, 2026 17:22
b747a27 to
da14bb5
Compare
zzylol
marked this pull request as ready for review
November 24, 2026 17:23
zzylol
added a commit
that referenced
this pull request
Nov 24, 2026
View file format 4: each (view, window) fragment is zstd level 1 compressed, and DDSketch and exact state columns are stored in a lossless compact form (state_codec.rs) and rebuilt byte for byte into the mapped layout on read; text keys are varint deltas. Formats 2 and 3 are set aside at startup. Demo segments re-encoded: 7.23 GB -> 0.94 GB (DDSketch 1 s 160 -> 17 B/row, counter 72 -> 7.4, sum 40 -> 3.2). Cold reads of pages not in memory 2-5x faster; page-cache-resident window decode 1-3 ms slower per 10k rows. Review fixes: exact cache charge for rebuilt DDSketch and label columns, write-size cap, per-thread zstd contexts.
zzylol
added a commit
that referenced
this pull request
Nov 24, 2026
…, label columns, RFC 3339 times, format 4 (#871) Ports #865, #869, #868 and #866 from the tiered-view-storage branch to main: a read-back view window is charged its own bytes; label text columns are rebuilt from the series identity; query times are read as Unix seconds or RFC 3339; view fragments are compact and zstd-compressed (view file format 4; formats 2 and 3 are set aside at startup). Tests adapted to main's APIs.
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.
Review first
*.stale) and are not readable by this build. A data plane restarted on this build starts its views empty.Why
View files wrote almost as many bytes as the raw samples they summarize. In the live demo, a DDSketch of the ten samples a series has in a 1 s pane took 160 B a row on disk: an 88-byte head that repeats alpha, the admission rate and a count on every row, then sparse
u32bucket keys,u32offsets andu32text keys. An exact counter took 72 B a row and an exact sum 40 B.What
Before this PR (format 3): a fragment is one view's rows of one window, by column, uncompressed. State columns are in the executor's mapped layout. Label columns are already rebuilt from the series identity (#869).
After this PR (format 4): the fragment is still columnar, one per (view, window), so a cold read still reads one fragment. Two changes:
data_plane/src/state_codec.rs):u32length, then the compressed columnar bytes. One zstd context per thread.Interfaces
The window cache's charge for a read-back window stays
window_batch_bytes(batch)plus the state bytesreadreturns (#865). The rebuilt DDSketch buffer is shrunk to its length, so the charge equals what the window holds. Each label column read back from the series identity holds its own copy of the identity keys, as in #869, so the charge is exact.Measurements
Bytes per row on the demo's segments. The data is 27 minutes of format-2 segments of the 1 s workload (7.2 GB), re-encoded offline. Bytes include the record frame.
For the 30 s workload, on a copy of its first 10 minutes of segments, by view write rate: format 2 wrote 2.59 GB/h, zstd 1 alone 0.78 GB/h, and format 4 0.57 GB/h. #869's label columns overlap with part of the "compact only" column: in format 3 the label text keys were already gone.
Encode and decode time.
view_read_bench(extended here with a family argument and write timing) was run at 10,000 series × 40 windows of 10 samples each, on one pinned core, 3 runs each, base (format 3) against this PR. The table shows the median ms per window.The bench's synthetic states repeat across series, so its byte counts (1–5 B/row) are not representative. The bytes per row above come from the demo's segments.
What this means for query latency. A window-cache miss on a page-cache-resident 10k-row window costs 1–3 ms more CPU. A miss whose pages left memory costs 5–12 ms less. With #865, misses run at about 5 windows/s in the demo replay, about +15 ms of CPU per second at worst. Hits, which are ≈99% of reads, are unchanged.
Tests
state_codecunit tests:a_ten_sample_ddsketch_window_is_stored_compactpins a 1,000-series window at 30,196 B, against 124,352 B in the mapped layout. It also fails if the writer's DDSketch output ever falls back to the mapped layout.cold_reads_report_state_bytes_and_share_one_dictionaryreplaces the borrow test.label_columns_are_read_back_from_the_series_identity(feat(data_plane): read view label columns back from the series identity #869) now checks only the fragment length order, since fragments are compressed.every_family_reads_back_from_its_fragmentcovers answer parity for every family through segments.cargo fmt --check;cargo clippy -p data_plane --all-targets -D warnings;cargo test -p data_plane --lib(store, persist, segment, window_cache, series_ids, state_codec: 37 passed);--test view_cache_charge,view_tiering(9),view_persistence(7),view_cold_allocations,view_memory,ingest_shards(9).view_tiering::view_files_stay_bounded_by_retentionandingest_shards::a_shard_running_ahead_does_not_close_windows_early, which failed in an earlier run, pass on both the base branch and this PR. No failure reproduced.Reviews
Independent review passes, one for correctness and one for dead code, duplication and efficiency, were run on the rebased change. Fixed here:
compressrefuses a fragment pastMAX_FRAME_BYTES, instead of writing one that a read would reject;view_cache_chargeexact: sharing one buffer overcharged by about 40%;encode_text_keysreserves its output, and the module docs no longer describe in-place reads.Found correct: the round trip of every column kind, including
IDENTITY_LABELover varint keys; lossless DDSketch and exact encodings (NaN payloads, ±inf, −0.0, i64 timestamp extremes); damaged input is rejected without panics; formats 2 and 3 are never misread.Left for follow-ups:
Mmapread mode, if a bench showspreadties;