Repository navigation
Conversation
…79) for its sample-block codec trait
…en at seal) for compressed-sample windows
…plane's codec; view files store the sealed blocks; sealed-window reads only
…, exclude compressed-sample windows
…ed on main (0b3c21450); sketchlib at its pin
… (0c302c4ea); sketchlib at its pin
Contributor
Author
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
SampleBlockCodectrait; its ownPlainSampleBlockCodecstores 16 bytes per sample.data_plane::sample_blocks::CompressedSampleBlockCodec. A block is codec 0 (Gorilla: delta-of-delta timestamps, XOR values) while open. When it seals, it keeps the shorter of codec 0 and codec 1 (decimal mantissas as zigzag varints in a zstd frame; short decimals only). Ingestion and query runs build with it (RunContext::with_sample_block_codec). View files store the sealed blocks verbatim. The data plane declares sealed-window reads only until it serves a chain's open window.quantile_over_time(0.5, data[1m])without raw data is answered from decoded blocks, also after a restart.Review guide
sync/planner-main-1760a69f(feat: execute ASAPPlanner main's InstallablePlan through asap-executor #852). Not stacked on data-plane: tiered view storage with zero-copy state views #855; data-plane: tiered view storage with zero-copy state views #855 can pin or merge this branch.0c302c4ea, the head of ASAPPlanner #1445, which adds the trait. That head is rebased onto current Planner main (including #1440/#1442/#1447/#1448/#1451/#1452/#1455), so feat: execute ASAPPlanner main's InstallablePlan through asap-executor #852's multi-level window chains are kept. In that head, compressed-samples chains are offered at ingestion time only, and a decode's output equals a rawTimeRangeread.asap_sketchlibstays at389530ce, the rev that commit pins. The pin moves to #1445's merge commit when it merges.sample_blocks/mod.rs: the trait implementation.sample_blocks/block.rs: the codec; its module doc is the byte format.persist.rs: the newStoredValue::CompressedSamples.control_plane/src/lib.rs:backend_capabilities.CompressedSamples::from_bytes: never panics; decompression is capped at 20 bytes per sample.unsealed_window_reads: falseinbackend_capabilities.RunContextwiring (2 lines);compressed_samples: they test a sketch's own state, or the absence of an exact plan;Behavior: before → after
Workload:
quantile_over_time(0.5, data[1m])andmax_over_time(data[1m])every 10 s, exact (no accuracy given).datahas 2 series at 1 sample/s.raw_data_retained: false. This is the newcompressed_sample_windows.rs.846a70a)Scan → SummaryTumblingWindowChain[CompressedSamples] (a width that tiles the readers) → DecodeSamplesInRange 1m (sealed reads) → Aggregate quantile / maxInterfaces
sample_blocks/mod.rs,sample_blocks/block.rs,persist.rs,control_plane/src/lib.rsUsage:
CompressedSampleschain:plan_workloadunderbackend_capabilities, so with aligned widths and sealed reads.RunContext::new(..).with_sample_block_codec(sample_blocks::codec())) append each sample to its series' open block and seal it at the window's end. The view rows hold the sealed bytes.StoredValue::CompressedSamples(block)verbatim; loading restores the state withCompressedSamplesAccumulator::restore_from_disk(block, codec()).DecodeSamplesInRangecallssamples_inon each window's block and hands the rows to the exactAggregate.How #855 uses this
CompressedSamplesAccumulator::block(), the bytesOpenSampleBlock::sealreturned. Store them verbatim as a blob in the fragment's state column; no re-encode.persist.rsdoes the same in today's record format (StoredValue::CompressedSamples). It re-encodes only a block written by another codec (a state built by a run without the data plane's codec).CompressedSamplesAccumulator::restore_from_disk(bytes, sample_blocks::codec()), which validates. The executor'sDecodeSamplesInRangethen callsSampleBlockCodec::samples_in(anddecode) on the bytes. A blob needs no state decode step before the query decodes it.OpenSampleBlock::sealdoes not consume, so it doubles as the open window's snapshot. data-plane: tiered view storage with zero-copy state views #855 can instead serve the open window from its raw panes, as its design says. Either way, flipunsealed_window_readstotrueinbackend_capabilitiesin the PR that serves it; until then plans read sealed windows at aligned widths.Algorithm changes
Sample-block codec (port of the closed
asap_sketchlib#268 implementation, unchanged in format):appendcodes a newer sample with a delta-of-delta timestamp code (1–68 bits) and an XOR value code reusing the previous leading/trailing-zero window.sealalso tries codec 1 when every value is finite, not −0, and exactlym / 10^Dwith|m| < 2^53,D ≤ 17. Codec 1 writes varints of the mantissa deltas or deltas of deltas (the shorter), compressed with zstd level 1.sealkeeps the strictly shorter codec.mergeis a linear merge of both blocks' samples, then a seal.appendis O(1) for newer samples, O(n) otherwise.sealis O(n) plus zstd.decode/samples_inare O(n); codec 1 decompresses once per call, bounded by 20 bytes per sample.Bake-off (
sample_block_bakeoff.rs). Release build, 1,000 series × 3,600 samples at 1 s, through the trait. One core of a shared 2.0 GHz server, so timings are noisy.decodevalidates the block (one decode pass) and then decodes it (a second pass). A single-pass decode is a follow-up if query profiles show it.Decisions and open questions
Decided:
asap_sketchlib(closed fix(backend): cms_params accepts canonical w/d + legacy row_num/col_num #268) or ASAPPlanner. The format and tests are unchanged from fix(backend): cms_params accepts canonical w/d + legacy row_num/col_num #268.sample_blocks::codec()), with no option to switch it.unsealed_window_reads: falseuntil the open window is served. The data plane's view read returns sealed windows that tile the range, so an unsealed read at a mid-windowTwould be refused ("no rows tiling").compressed_samples. Under the new pin, exact decode plans beat DDSketch/KLL on their small workloads, so without the exclusion they would test the wrong state.Needs reviewer decision: none.
Not in this PR:
cargo clippy -- -D warningsunder Rust 1.98 flagstype_complexityinprometheus.rsandseries_ids.rs. This PR does not touch those files, and the lints are left as they are.Verification
data_plane --test sample_blocksdata_plane --test compressed_sample_windowsdata_plane --libcompressed_samples_are_stored_as_their_sealed_blockcontrol_plane --test plan_workloadcompressed_samplesdata_plane --test window_levelsdata_plane --test precompute_pooldata_planetests:concurrency(1),ingest_shards(9),no_forward(3),planner_executor_answers(10),planner_executor_parity(2),range_queries(4),result_cache(3),series_ids(2),server(10),shared_results(2),view_memory(1),view_persistence(7)cargo clippy --workspace --all-targets -- -D warningstype_complexityin untouchedprometheus.rs/series_ids.rs-A clippy::type_complexity; left as they arecargo fmt --all -- --checkcargo check --workspace --all-targets0c302c4eaFollow-ups
unsealed_window_reads: true.column_compressed_bits_per_samplefrom the bake-off's measurement.