Skip to content

feat(data_plane): tables stored by series key, other columns as per-chunk dictionary fields - #904

Draft
zzylol wants to merge 3 commits into
feat/raw-read-label-pushdownfrom
feat/table-series-key
Draft

zzylol wants to merge 3 commits into
feat/raw-read-label-pushdownfrom
feat/table-series-key

Conversation

@zzylol

@zzylol zzylol commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

A SQL table is stored as series: each row is a sample of the series named by all its text columns. Event data (network packets) almost never repeats a label set, so every row becomes its own series: N1 on packets holds millions of series per 5 minutes. Each row then pays for interning a label map, per-round text-column builds, and a series table that never shrinks. Profile in the network eval: ~42% of q1 in Chunk::column, ~94% of decode in series interning, peak RSS 4.5 GB for 283 MB of raw rows.

What

A table can declare its series key (deployment config, --table-layouts FILE):

{"packets": {"series_key": ["src_p16"]}}

A row's series is then {__name__=<table>, <key columns>}. Every other column is a field: a typed column inside the series' chunks (text fields are dictionary-coded per chunk). Metrics and tables without a layout are stored as before. The planner is unchanged: it already treats a SQL table as columns.

Before / after (N1 5-minute intent, synthetic x1, 6.6 M rows, in-process packets_bench, 16 threads)

before (#902 head) after, no layout after, packets keyed by src_p16
series interned ~5.07 M 5.07 M 520
round (q1+q2+q3), rounds 1-2 11.9-12.6 s 10.9-11.7 s 0.55-0.56 s
q2 / q3 (query time, 5 min of raw rows) 7.2-7.7 s / 4.8 s 6.6-7.3 s / 4.3 s 0.29 s / 0.26 s
Remote Write acknowledged (6.6 M rows, unpaced) 25.5 s 25.3 s 11.7 s
engine CPU per ingested row 6.6 µs 6.1 µs 4.5 µs
peak RSS 7.8 GB 8.0 GB 1.9 GB
raw bytes 214 MB 214 MB 447 MB (field codes + dictionaries)
answers (9 query results) — identical identical

1-hour N1 (72.6 M rows of [0, 3630 s), keyed by src_p16, 629 series):

  • Query-at-a-time plan: q2 / q3 scan the hour of raw rows at query time and take 3.3-3.8 s / 2.9 s; a round takes 6.2-6.8 s. Raw data is 5.0 GB (72 B/row); peak RSS is 7.7 GB, including the bench's own 1.7 GB copy of the rows.
  • Full-intent plan: q2 takes 17.9-18.4 s, q3 0.1 s. This q2 merges the kept per-(src_ip, src_p24, src_p16) states rather than reading raw rows, so it does not go through this PR's code path. It is executor merge work, which belongs to the parallel-exec branches.
  • The "before" layout was not run for 1 hour: it holds tens of millions of series.

How

  • table_layout.rs (new): TableLayouts (--table-layouts, EngineOptions::table_layouts, Limits::table_layouts) and split: a row's labels -> (series key, fields).
  • Remote Write decode: a declared table's row interns only its key labels. Its other labels become RawSample::fields, sorted by name, with names interned once. These rows are not put in the per-thread label-bytes cache, which today keeps every row-series.
  • store::Chunk:
    • fields: per-chunk dictionary text columns.
    • A sealed pane of a keyed table is compacted sorted by (series, time); ties stay in arrival order.
    • A key-label column is a dictionary whose keys are the chunk's series codes (zero copy) over one value per series, so there is no per-row work and no hashing.
    • Built label and identity columns are cached in the chunk (built), so a sealed pane's columns are built once in its life, not once per round. Compaction and eviction drop chunks together with their cached columns.
    • ahash is used for the store's internal maps.
  • Pushdown (feat(data_plane): raw reads return only the series a Scan's label predicates select #902) by column role:
    • key-column restrictions select series, as before;
    • field-column restrictions find the allowed dictionary entries once per chunk, skip a chunk that has none, and otherwise keep only matching rows (one byte lookup per row).
    • A field restriction is never applied to the series. Without this split, a field predicate would select no series.
  • Gauge asap_series_interned. Push precompute mode with --table-layouts is refused: push pipelines do not carry fields.
  • examples/packets_bench.rs: feeds a net_dump packet file as the eval's feeder does, runs an intent's rounds, and prints ingest CPU per row, raw bytes, series interned, RSS and per-query latency. It writes answers for comparing layouts.

Tests

  • Unit:
    • table_layout: parse, refuse, split.
    • remote_write: one series per key value, fields carried, a missing key label.
    • store: a keyed read returns the same rows as the label layout; sealed panes are sorted; dictionary sizes; columns built once across runs; cached bytes counted and following compaction and eviction; pushdown on key and field columns.
  • E2E intent_sil_modes::keyed_table_answers_equal_the_label_layout_and_exact, in all three planning modes, for keys [host], [host, user] and [user]:
    • answers are identical to the label layout (and exact);
    • series interned are 4 / 12 / 3;
    • q2 bound to one host reads a quarter of its rows, by series or by field values.
  • The full cargo test -p data_plane --no-fail-fast passes.

Deferred

  • Arrow IPC row endpoint and typed Int64 field columns. Fields are text today; value is the Float64 field.
  • Slicing selected series as zero-copy row ranges of sorted chunks. Today selected rows are copied in one pass.
  • Remapping dictionaries per entry at compaction instead of per row. This is ingest-shard CPU: 17 s vs 6 s for 6.6 M rows in the bench.
  • Dropping fields that no Scan reads.
  • Executor: packing group tuples into an integer key (ASAPPlanner). Parallel scan/aggregate is in feat/parallel-rounds / feat/parallel-query-exec. Partitioning stays by series id, as there.
  • Re-measuring the planner's per-row scan cost inputs on the keyed layout.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi

zzylol and others added 3 commits December 3, 2026 18:20
Tests for selecting series by a Scan's label predicates (label = 'v',
IN, OR of = on one label) in raw reads: recognition and its negative
cases, the label index, per-chunk selection and skipping, shared
conversions kept apart by selection, series partition composition, and
an end-to-end intent round answering the same with and without pushdown
while reading only the bound host's rows. Stubs keep today's behaviour;
RawData::read returns RawRead with rows in the time range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es select

A raw read recognizes, among its Scan's predicates, label = 'v', label IN
(...) and an OR of = on one label, on label columns (a SQL table's text
columns, a metric's labels), and returns only the rows of the series
they select; everything else is still applied by the executor, so the
answers do not change. Per read, each series is judged once (a verdict
by dense series id); per chunk, its distinct series are checked, a chunk
with none selected is skipped without touching its rows, and the
selected rows are copied in one pass (Chunk::select, which
Chunk::in_partition now uses). A selected cut of a stored chunk is
converted once per range request and selection, apart from the whole
chunk's conversion.

/metrics counts the query runs' raw reads, their rows in the time range
and the rows returned (asap_query_raw_read_*_total). --no-label-pushdown
(EngineOptions::label_pushdown) reads every series, for comparison.
No global label index: the per-chunk check walks each chunk's series
list either way (rows are in arrival order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hunk dictionary fields

A table may declare its series key (--table-layouts): a row's series is
its key labels, its other labels are fields stored as dictionary-coded
columns of the chunk. Sealed keyed panes are sorted by series then time;
key-label columns are dictionaries over the chunk's series codes and are
built once per chunk (cached across rounds); label pushdown applies key
restrictions to series and field restrictions to dictionary entries.
Metrics and tables without a layout keep one series per label set.

N1 5-min (synthetic x1, 6.6 M rows): round 12.5 s -> 0.56 s, series
5.07 M -> 520, peak RSS 7.8 GB -> 1.9 GB, answers identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
@zzylol zzylol added enhancement New feature or request area: data plane Runtime ingestion, storage, and query-serving data paths feature: workload optimization Cross-query sharing, costing, placement, and physical configuration selection labels Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: data plane Runtime ingestion, storage, and query-serving data paths enhancement New feature or request feature: workload optimization Cross-query sharing, costing, placement, and physical configuration selection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant