Skip to content

perf(data_plane): x10 ingest/precompute costs: distinct-value label columns, compact on flush, shared metric Arc; pin ASAPPlanner#1569 - #908

Merged
zzylol merged 8 commits into
eval/2026-12-backendfrom
perf/ingest-x10
Dec 4, 2026
Merged

zzylol merged 8 commits into
eval/2026-12-backendfrom
perf/ingest-x10

Conversation

@zzylol

@zzylol zzylol commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem. At the paper's 10x scale (suite_v2 observability/security intents, 69 queries, 840k rows/s on a 56-thread server), the data plane ingests on time, but its precompute and its query rounds cost too much. A 10 s window run re-built per-series label text and re-hashed it (one text per row) for each of its 24 views, because the window read the per-request chunks before they were compacted. Only 13 of 61 rounds ran, with a group latency p99 of 170 s.
  • Change. Label columns are dictionaries over distinct values. A shard compacts its closed panes when it flushes. Series of one metric share one metric Arc. There is an opt-in --precompute-parallelism. The branch pins ASAPPlanner perf/ingest-x10 (ASAPPlanner#1569: hash equi-join, KMV merge, group-table entry cache).
  • Effect. Answers are unchanged (golden check). At 1x x10, precompute CPU fell from 2.07 to 1.24 core-s per M rows, query CPU from 5.93 to 4.70, and total from 9.85 to 7.61. Group latency p99 fell from 170 s to 76 s. At 2x (1.68M rows/s) ingest keeps up (watermark lag p99 2.7 s), with precompute CPU at 1.09 vs 1.95 and total CPU at 4.17 vs 5.40 core-s per M rows.

Review guide

  • Base: eval/2026-12-backend 19f72f2 (eval build 3). The last pin commit moves the ASAPPlanner rev from 39a25ee3 to the head of ASAPPlanner#1569 (39a25ee3 + 2 executor commits).
  • Read first: data_plane/src/store.rs (Chunk::label_column, Chunk::bytes, RawData::append, RawData::seal_through), then data_plane/src/engine.rs (serve_shard's Flush arm) and data_plane/src/ingestion.rs (Routing::flush_seal_through, Precompute::with_parallelism). These need care: the order of rows inside a compacted pane, and the memory accounting of label columns.
  • series_ids.rs (value ids, shared metric Arc) is small and mechanical.

Behavior: before → after

The intents runner launches the data plane with the suite_v2_noOE.c10r10h2 intent_full plan, on 48 threads, with --precompute-mode window --table-layouts {"login_fail":{"series_key":["user"]}} --query-parallelism 56 --query-pool-threads 56. One ifeed process feeds it at 840k rows/s (10 minutes of history, then 60 rounds every 10 s). Before/after on the same input and flags:

run binary rate rows/s (data plane) watermark lag p50/p99/max s ingest+precompute+persist core-s/M rows precompute phase core-s/M rows query core-s/M rows total core-s/M rows RSS T0→end GB rounds ran/total group latency p50/p99 s
base2 eval build 2 1x 840k 2.53/4.04/4.84 1.81+2.12 2.07 5.93 9.85 24→40 13/61 30/170
opt2-1x opt2 1x 840k 2.49/3.39/3.40 1.76+2.19 2.13 6.11 10.05 22→38 14/70 30/168
r3-1x r3 1x 840k 2.44/3.14/3.55 1.67+1.26 1.23 3.14 6.07 25→40 15/70 17/128
r5-1x r5 1x 840k 2.51/3.17/3.50 1.67+0.77 1.71 5.27 7.71 25→35 18/64 15/71
r6-1x r6 1x 840k 2.55/3.33/4.57 1.62+1.30 1.24 4.70 7.61 25→38 18/70 19/76
ev-2x-f4 eval build 2 2x 1680k 2.25/2.37/3.30 1.52+1.98 1.95 1.90 5.40 33→54 12/62 32/285
r5-2x-f4 r5 2x 1680k 2.29/2.73/2.95 1.44+0.75 1.51 2.71 4.90 36→55 15/66 28/129
r6-2x-f4 r6 2x 1680k 2.25/2.70/2.83 1.37+1.13 1.09 1.66 4.17 35→54 15/68 28/135
  • Rows/s is what the data plane accepted. The lag is wall clock minus watermark (2 s of allowed lateness plus the 250 ms feed chunk is the floor). CPU is per million rows accepted while the feeder ran: thread classes, except the precompute phase column (asap_phase_cpu_seconds_total{phase="precompute"}, which also counts its pool CPU). RSS is VmRSS at the first round and at the end of the feed.
  • base2 ran with 15 minutes of history, the others with 10 minutes. opt2 = the label-column commit alone. r3 = + flush compaction + planner join/entry cache. r5 = + KMV merge + shared metric + --precompute-parallelism defaulting to 56. r6 = this PR's head (precompute parallelism opt-in, default 1).
  • 2x rows: 4 ifeed processes. Their unpaced preloads finish at different times, so 70M rows of history arrived behind the watermark and were dropped as late. The live phase had no drops. The 2x round numbers are therefore over incomplete history; only the ingest columns count there.

Interfaces

data_plane/src/engine.rs

 /// The engine's options (stays; one field added).
 pub struct EngineOptions {
     pub ingestion: IngestionOptions,
     pub max_queued_samples: u64,
     pub max_precompute_backlog: usize,
     pub ingest_threads: usize,
     pub precompute_threads: usize,
     pub slow_refreshes: Vec<SlowRefresh>,
     pub check_task_inputs: bool,
     pub shard_delay_ms: u64,
     pub persist_threads: usize,
     pub max_persist_backlog_bytes: u64,
     pub persist_delay_ms: u64,
     pub no_forward: bool,
     pub run_memory_limit_bytes: usize,
     pub query_threads: usize,
     pub query_parallelism: usize,
+    /// Parts each precompute window run's grouped builds split into on the
+    /// query worker pool (built when `query_parallelism` is above 1);
+    /// default 1: each window runs on its precompute thread. Above 1 a
+    /// window commits sooner for more CPU (the pool's split overhead).
+    pub precompute_parallelism: usize,
     pub query_pool_threads: usize,
     pub query_min_split_rows: Option<usize>,
     pub share_one_evaluation_results: bool,
     pub label_pushdown: bool,
     pub table_layouts: crate::table_layout::TableLayouts,
     pub query_time_results_retention_ms: u64,
     pub query_time_results_max_bytes: usize,
     pub result_cache: bool,
     pub result_cache_max_bytes: usize,
     pub view_dir: Option<std::path::PathBuf>,
     pub view_sync_interval_ms: u64,
     pub view_cache_max_bytes: Option<u64>,
     pub view_cache_idle_ms: Option<u64>,
     pub view_segment_ms: i64,
     pub view_read: ViewRead,
     pub cold_decode_delay_ms: u64,
     pub unpersistable_views: Vec<PhysicalASAPNodeId>,
     pub precompute_mode: PrecomputeMode,
     pub push_batching: crate::push::MorselBatching,
     pub precompute_memory_budget_bytes: Option<u64>,
     pub panic_in_combine_of_window_end_ms: Option<i64>,
 }

data_plane/src/main.rs

+    /// Parts each precompute window run's grouped summary builds split
+    /// into on the query worker pool (the stored states are the same for
+    /// any value): above 1, windows commit sooner for more CPU. Default 1.
+    #[arg(long, default_value_t = EngineOptions::default().precompute_parallelism)]
+    precompute_parallelism: usize,

data_plane/src/ingestion.rs

 impl Routing {
+    /// Where a shard whose newest sample is at `newest_ms` compacts its
+    /// panes when it flushes: `newest_ms` minus the allowed lateness.
+    pub fn flush_seal_through(&self, newest_ms: Option<i64>) -> Option<i64>;
 }
 impl Precompute {
+    /// Splits each window run's grouped builds into `parallelism` parts on
+    /// the worker pool; the pool's CPU counts as the run's.
+    pub fn with_parallelism(mut self, parallelism: usize) -> Self;
 }

data_plane/src/series_ids.rs

 impl Series {
+    /// The id of this series' value of the label `name` (an interned name,
+    /// compared by address); `None` without the label. Equal texts share an id.
+    pub fn value_id(&self, name: &'static str) -> Option<u32>;
 }

data_plane/src/store.rs

 impl RawData {
-    pub fn seal_through(&mut self, watermark_ms: i64);
+    /// Compacts each pane ending at or before `watermark_ms`; whether it compacted any.
+    pub fn seal_through(&mut self, watermark_ms: i64) -> bool;
 }

Usage (end to end): data_plane --plan plan.json --intent intent_plan.json --precompute-mode window --table-layouts layouts.json --query-parallelism 56 --query-pool-threads 56 [--precompute-parallelism 8]. Remote Write requests go to the shards (RawData::append, one map lookup per run of one metric and pane). On each coordinator pass, every shard compacts the panes behind flush_seal_through(newest) and sends its raw data with the flush. The windows that pass closes run Precompute::refresh, whose Scans read one chunk per pane; each label column is built over the distinct values (Chunk::label_column via Series::value_id). Each grouped build hashes each value once per batch (ASAPPlanner#1569). The intent round reads the committed views; OU_avg_node_* joins by hash and H_traces_* merges KMV states by sorted union.

Algorithm changes

Label columns over distinct values (Chunk::label_column)

  • Problem: a label column was a dictionary with one entry per series in the chunk, keyed by the series codes. For a 10 s pane of a 100k-series table, every read copied ~100k label texts per label, and every grouped view hashed them all.
  • Before → after: StringArray::from_iter_values(series.map(|s| s.get(name))) keyed by codes → per series, look up value_id(name) (assigned once when the series is interned), map each distinct value id to a dictionary entry, and key each row by its series' entry.
  • Correctness: every row reads the same text as before ('' without the label). The executor reads dictionaries by value. Golden check: identical answers. Test: a_label_column_has_one_entry_per_distinct_value.
  • Complexity: per chunk and label, O(series) text copies and hashes → O(series) id lookups + O(distinct values) copies + O(rows) key gather. Memory accounting now counts a label column's own keys.

Compact on flush (serve_shard, Routing::flush_seal_through)

  • Problem: a coordinator pass closes windows using the raw data the shards sent with the flush, before that pass's Maintain compacted the panes. So a window run read one small chunk per Remote Write request, with about one dictionary entry per row.
  • After: at Flush, a shard compacts the panes that its own newest sample puts behind the allowed lateness, and only then sends its raw data.
  • Correctness: compaction already happens at Maintain with the same function; this only moves it earlier. A sample that arrives later for a compacted pane adds a chunk, as after any seal. Rows of tables without fields keep their order. Rows of keyed tables are sorted by series and time, as seal_through always did, so window runs now see that order. Answers are identical (golden check).
  • Cost: the same compaction work, done once and earlier. A flush with nothing to compact is not counted as an append run.

Shared metric Arc (series_ids::intern_pairs)

  • Routing::route and RawData::append compare a sample's metric with the previous one by address first. Each series held its own Arc, so that check missed whenever the series changed, and the code fell back to comparing texts per sample. Series of one metric now share one Arc.

Opt-in precompute parallelism (Precompute::with_parallelism)

  • A window run's grouped builds split by group key on the query pool, using the executor's contract (RunContext::with_parallelism: same states for any part count). Measured (r5, enabled by default there): the rounds' data wait fell from ~15 s to ~12 s, but the precompute phase cost +39% CPU (1.23 → 1.71 core-s per M rows), from rayon split and idle-steal overhead. So it defaults to 1.

Decisions and open questions

  • Needs reviewer decision: whether eval launches should pass --precompute-parallelism (fewer missed rounds for more CPU). Default here: off.
  • Decided (2026-12-04): suite_v2 at x10 must launch with --precompute-mode window --table-layouts {"login_fail":{"series_key":["user"]}}; the intents runner does so now. Without it, login_fail (user × src × target) interns about one series per row: RSS grew 5-10 GB/min (46 GB after 6 minutes) with no plateau. With it, series level off at ~5M.

Verification

scope result newly failing vs base notes
cargo test --release -p data_plane --no-fail-fast all pass except 1 none ingest_shards::a_shard_running_ahead_does_not_close_windows_early fails on the base too (pre-existing since #902, see the eval build record)
new unit test store::tests::a_label_column_has_one_entry_per_distinct_value pass a label column has one entry per distinct value; a series without the label reads ''
golden check: fixed suite_v2.c1r1h2 input (300 s, seeded), 15 rounds × 68 queries, eval build 3 vs this head 822/828 identical the 6 others are round 1, where the eval build fails with "raw samples … evicted" because the unpaced preload outruns round 1; this head answers them, with the same answers the eval build gives when the preload stops before the eviction
x10 runs on a 56-thread server table above perf LBR flame graphs before and after are in the report

Follow-ups

  • Feeder: one ifeed live thread tops out near 840k rows/s, which is the x10 rate. Split feeders race in the unpaced preload, and the slow part's rows are dropped as late. The intents runner now uses one feeder for LightconeDB and caps it at 700k rows/s. A preload-then-split-live feeder would lift that cap.
  • Remaining round latency at x10: SE_anomalous is a query-time raw scan of auth over 1 h (planner gap). OB_fast_5m, OB_endpoints and OF_q2 (~30 s) merge all groups before the bound IN filter. placeholders::bind re-serializes and walks the whole plan JSON per bound query (~7% of process CPU during rounds).
  • Push precompute: all 5 suite_v2 refresh groups combine series (Reduce), so the push probe rejects them. The "Merge" combine class in docs/design/parallel-precompute.md would move this work onto the 12 ingest shards.

🤖 Generated with Claude Code

zzylol and others added 8 commits December 4, 2026 09:31
A raw read's label column was a dictionary with one entry per series of the
chunk: every read copied each series' label text, and every grouped reader
hashed it. Series now carry per-label value ids (assigned at interning), so a
label column is a dictionary over the label's distinct values in the chunk
(one entry per value), built with no text lookup per series. RawData::append
collects each run of one metric and pane before touching the pane map.

Answers are unchanged (golden suite_v2 c1 rounds identical).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The windows a coordinator pass closes read the raw data the shards sent with
the flush, before that pass's Maintain compacted the panes: a window run read
one small chunk per Remote Write request (one label-dictionary entry per row).
A shard now compacts the panes its own newest sample puts behind the allowed
lateness when it flushes, so the closing windows read one chunk per pane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e3 + hash equi-join, group table entry cache)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every series held its own Arc of its metric name, so the shard router's
'same metric as the last sample' check (by address) missed on every series
change and fell back to comparing texts per sample. Series of one metric now
share one Arc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the worker pool

A round waits for the windows ending at its evaluation time to commit; a
10 s window of the x10 suite took ~10-15 s on one precompute thread, so
rounds waited ~15 s for data and the next round was missed. A window run now
splits its grouped summary builds into --precompute-parallelism parts
(default: --query-parallelism) on the query worker pool, like a query run;
the executor guarantees the same states for any part count. The pool's CPU
is charged to the precompute phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n it compacts

exports_phase_metrics expects one append run per request; the flush-time
compaction recorded one per flush even with nothing to compact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured at x10 (840k rows/s): splitting window runs on the pool cut the
rounds' data wait from ~15 s to ~12 s but cost +26% precompute CPU (rayon
split and idle-steal overhead). Default 1; --precompute-parallelism N opts in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol zzylol added enhancement New feature or request area: data plane Runtime ingestion, storage, and query-serving data paths integration: ASAPPlanner ASAPPlanner API, IR, candidate, and selected-plan integration labels Dec 4, 2026
@zzylol
zzylol merged commit 94d107e into eval/2026-12-backend Dec 4, 2026
1 check passed
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 integration: ASAPPlanner ASAPPlanner API, IR, candidate, and selected-plan integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant