Skip to content

perf(data_plane): x10 rounds: linear IN-list binding, a window's independent views run apart - #909

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

zzylol merged 7 commits into
eval/2026-12-backendfrom
perf/x10-rounds

Conversation

@zzylol

@zzylol zzylol commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem. At the x10 scale (suite_v2 c10r10h2 intent_full, 74 queries, 840k rows/s, eval build 4), only 8 of 57 10-second rounds ran, and each took 69–80 s. Two causes:
    • Binding a dependent query's IN-list (OB_fast_5m, OB_slow_30m, OB_endpoints, OF_q2) took ~30 s per query. The binding compared every value of the 3.3 MB serialized plan with each of the slot's 5000 placeholders, and it prepared the slot again for every node.
    • The 10 s window that a round waits for took ~9 s to commit, because all 24 views of the refresh group ran as one run on one precompute thread.
  • Change.
    • Binding looks placeholders up in hash sets (linear in the plan) and prepares each slot once per plan (PreparedSlot).
    • A refresh group's views that share no node below them (here, views over different tables) are compiled as separate parts. A window runs its parts at once, one thread each. This is on by default; --precompute-split-views false restores the single run.
  • Effect. Answers are unchanged (golden check below). Bound queries went from 29–31 s to 2–3 s. The group-0 window commits in ~1.9 s instead of ~9 s at the same CPU (16 parts). Rounds that ran went from 8 of 57 to 30 of 60, round duration p50 from 68.9 s to 15.7 s, and data wait p50 from 9.3 s to 1.9 s. Rounds are still above 10 s; the critical path is now query plans, not the data plane (see Remaining).

Review guide

  • Base: eval/2026-12-backend 659f1d6 (eval build 4). Three test-first pairs: binding linear (f990c5d → eb33b0d), slot prepared once (bc0ab5b → 29656bf), independent views apart (5e45fc7 → cdf237c, c58ee18).
  • Read first: data_plane/src/ingestion.rs, specifically independent_view_sets, Precompute::compute (the parts on scoped threads, error and CPU accounting), and computed (it now takes (root, rows)). Then data_plane/src/placeholders.rs (PreparedSlot, Rewrite::is_placeholder).
  • These need care: a part that fails fails the window, as the whole run did; and the CPU of a part's thread is charged to the precompute thread's phase CPU.

Behavior: before → after

A 56-thread host, suite_v2.c10r10h2 intent_full (build-4 plan), data plane on 48 threads with --precompute-mode window --table-layouts layouts.json --query-parallelism 56 --query-pool-threads 56, one ifeed at 840k rows/s, 10 min of history, 60 rounds at 10 s:

run binary 10 s rounds ran round duration p50/p99 s data wait p50/p99 s group latency p50/p99 s precompute phase core-s total core-s / M rows
b4-1x eval build 4 8/57 68.9/79.9 9.3/30.0 21.1/79.9 646 6.28
xr1-1x + hashed binding (eb33b0d) 20/60 21.1/40.4 8.7/27.4 13.3/38.4 693 7.52
xr1-pp8 + slot once (29656bf), --precompute-parallelism 8 26/60 18.7/38.3 6.6/27.4 12.0/35.9 706 8.68
xr1-pp16 same, --precompute-parallelism 16 25/60 19.5/31.7 6.7/20.2 13.9/28.8 723 8.80
xr3-1x + independent views apart (this PR's defaults) 30/60 15.7/21.3 1.9/9.8 7.0/19.6 793 8.42
xr3-pp8 same, --precompute-parallelism 8 29/60 16.4/21.5 1.7/8.4 7.5/19.9 930 9.33
  • Group-0 window (24 views, 10 s): ~9.0 s wall per window on one thread (b4/xr1) → 5.6 s with --precompute-parallelism 8 → 1.85 s with the views apart (16 parts), at ~9.7 core-s per window either way. The 60 s group goes from ~6.8 s to 2.5 s.
  • More rounds run, so query CPU per M rows rises (more queries are answered). Total core-s per M rows counts every thread class.
  • The precompute phase core-s is over the live phase. It is up ~14% with the views apart (793 vs 693), and the watermark lag p50 is 3.2 s vs 2.6 s (16 part threads per window run alongside ingest).
  • --precompute-parallelism adds nothing once the views run apart (xr3-pp8) and costs 17% more precompute CPU, so its default stays 1.

Per query, p50/p99 latency in seconds (10 s rounds that ran):

Q| run | binary | 10 s rounds ran | round duration p50/p99 s | data wait p50/p99 s | group latency p50/p99 s | precompute phase core-s | total core-s / M rows |
|---|---|---|---|---|---|---|---|
| b4-1x | eval build 4 | 8/57 | 68.9/79.9 | 9.3/30.0 | 21.1/79.9 | 646 | 6.28 |
| xr1-1x | + hashed binding (eb33b0d) | 20/60 | 21.1/40.4 | 8.7/27.4 | 13.3/38.4 | 693 | 7.52 |
| xr1-pp8 | + slot once (29656bf), --precompute-parallelism 8 | 26/60 | 18.7/38.3 | 6.6/27.4 | 12.0/35.9 | 706 | 8.68 |
| xr1-pp16 | same, --precompute-parallelism 16 | 25/60 | 19.5/31.7 | 6.7/20.2 | 13.9/28.8 | 723 | 8.80 |
| xr3-1x | + independent views apart (this PR's defaults) | 30/60 | 15.7/21.3 | 1.9/9.8 | 7.0/19.6 | 793 | 8.42 |
| xr3-pp8 | same, --precompute-parallelism 8 | 29/60 | 16.4/21.5 | 1.7/8.4 | 7.5/19.9 | 930 | 9.33 |

  • Group-0 window (24 views, 10 s): ~9.0 s wall per window on one thread (b4/xr1) → 5.6 s with --precompute-parallelism 8 → 1.85 s with the views apart (16 parts), at ~9.7 core-s per window either way. The 60 s group goes from ~6.8 s to 2.5 s.
  • More rounds run, so query CPU per M rows rises (more queries are answered). Total core-s per M rows counts every thread class.
  • The precompute phase core-s is over the live phase. It is up ~14% with the views apart (793 vs 693), and the watermark lag p50 is 3.2 s vs 2.6 s (16 part threads per window run alongside ingest).
  • --precompute-parallelism adds nothing once the views run apart (xr3-pp8) and costs 17% more precompute CPU, so its default stays 1.

Interfaces

data_plane/src/engine.rs

 pub struct EngineOptions {
     …
     pub precompute_parallelism: usize,
+    /// Whether a refresh group's views that share no node below them run
+    /// as separate runs of a window, at once, each on its own thread
+    /// (default true): the window commits after its slowest part. The
+    /// stored rows are the same either way.
+    pub precompute_split_views: bool,
     …
 }

data_plane/src/main.rs

+    /// Whether a refresh group's views that share no node below them run
+    /// as separate runs of a window at once, each on its own thread (the
+    /// stored rows are the same either way). Default true.
+    #[arg(long, action = clap::ArgAction::Set, default_value_t = EngineOptions::default().precompute_split_views)]
+    precompute_split_views: bool,

data_plane/src/ingestion.rs

 struct RefreshGroupRun {
     views: Vec<MaterializedView>,
     compiled: CompiledPhysicalDAG,
+    /// The group's run in independent parts (views sharing no node below
+    /// them); empty when there is one set.
+    parts: Vec<CompiledPhysicalDAG>,
     …
 }
 impl Precompute {
+    /// Runs the independent parts of a group's window at once, one thread
+    /// each, when `split`; else as one run. Same stored rows either way.
+    pub fn with_split_views(mut self, split: bool) -> Self;
+    /// For each refresh group, the runs a window is computed in.
+    pub fn view_parts(&self) -> Vec<usize>;
 }
+/// `views` (of one refresh group) in sets that share no node below them.
+fn independent_view_sets(index: &DagIndex, views: &[PhysicalASAPNodeId],
+    stop: &HashSet<PhysicalASAPNodeId>) -> Vec<Vec<PhysicalASAPNodeId>>;

data_plane/src/placeholders.rs

+/// A slot ready to rewrite plan parts: its placeholders and bound values
+/// as JSON, checked once.
+pub struct PreparedSlot { rewrite: Rewrite }
+impl PreparedSlot {
+    pub fn new(slot: &SlotBinding) -> Result<Self, String>;
+    pub fn rewrite(&self, json: &mut Json) -> Result<bool, String>;
+}
 struct Rewrite {
-    placeholders: &'a [Json],
-    values: &'a [Json],
+    /// The placeholders' JSON text, looked up rather than compared one by one.
+    placeholders: HashSet<String>,
+    /// The text of each `Utf8` placeholder.
+    placeholder_texts: HashSet<String>,
+    values: Vec<Json>,
     position: SlotPosition,
 }

data_plane/src/metrics.rs

 pub struct WindowLatency {
     …
     pub parts: AtomicU64,
+    /// The independent runs a window computes its views in at once.
+    pub view_parts: AtomicU64,
 }
+# asap_precompute_window_view_parts{group="…"}  (gauge)

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 (split views on by default). At startup Ingestion::new compiles each refresh group whole and, when its views fall into several independent sets (independent_view_sets), as one part per set. On each closed window, Precompute::compute runs the parts at once: the first on the precompute thread, the others on scoped precompute-part threads. It merges their rows by root, then commits them in window order as before. An intent round's dependent query binds its holes with placeholders::bind, which prepares each slot once (PreparedSlot) and rewrites only the nodes and the plan's other fields. The bound plan is compiled and run as before.

Remaining (not in this PR)

These are plan choices, not data-plane issues. The round critical path after this PR:

  • SE_anomalous, 12 s: the window-ratio rewrite is in the build-4 plan, but it merges 1 h of (host, user) exact counts ([285], shared with SA_top_hosts_1h and SF_q3; predicted 2.8 s) and 10 min ([297], predicted 2.0 s), then regroups by user. Profile: the executor's group table (GroupTable::column_parts/group_ids, ~30% of query-thread time) in merge_exact_split.
  • Raw exact p99 over 5 min of latency, 9 s: OA_p99_5m, OE_p99_now and OF_q1 share one query-time scan plus exact quantile ([0]→[2]; predicted 3.3 + 5.7 s). The planner chose it knowing its latency. OF_q2/OF_q3 come after it, so the OF chain is ~9.5 s.
  • SB_q3, 9–14 s: a query-time exact distinct over every row of 1 h of login_fail, because the plan prices src IN $SB_A as if it selected series, while the layout keys series by user. The planner side is fixed in ASAPPlanner#1570 (series_key_columns). With it, the plan keeps a KMV chain, at ~108 GB of predicted state at x10. Deploying that is an eval decision.
  • Filter before merge for the shared time merge [143] (OC_p99_nodes, OE_nodes, OF_q2): after this PR those queries take 0.2–2.3 s, and [143] is one merge per round shared by three bindings, so a per-binding merge would trade sharing for less work. Not done.

Tests

  • data_plane lib: 129 passed. precompute_pool: 7 passed (new independent_views_of_a_window_run_apart_with_identical_views: byte-identical view files over every public workload plan without KLL, ≥3 plans parted). push_precompute, window_levels, intent_rounds, shared_results: pass.
  • Golden (suite_v2.c1r1h2, 15 rounds, fixed input, build 4 vs each binary): 896 of 896 query evaluations are the same (620 answered) for eb33b0d, 29656bf, cdf237c, cdf237c with --precompute-split-views false, and the head c58ee18. With --precompute-parallelism 8, 878 are the same. The other 18 are round-1 queries that build 4 fails ("raw samples … are evicted", a timing artifact noted in the build-4 record) and this binary answers. No answered evaluation differs.
  • cargo clippy -p data_plane reports two pre-existing errors in files this PR does not touch (metrics.rs:653, table_layout.rs:74).

🤖 Generated with Claude Code

zzylol and others added 7 commits December 4, 2026 17:34
…e plan's size

Failing test first: a plan with 30 IN-list holes of 2000 placeholders each;
binding two of them must take well under the budget (the current binding
compares every plan value with every placeholder, ~30 s per bound query at
the x10 scale).

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

The binding compared every value of the serialized plan with every
placeholder of the slot (and Utf8 texts again in the leftover check), so a
bound query cost plan size x placeholders: with 5000-value IN-list holes in
a 3.3 MB x10 plan, ~30 s per bound query (OB_fast_5m, OB_slow_30m,
OB_endpoints, OF_q2). The placeholders' JSON texts and Utf8 texts are now
hash sets, and only one-level (scalar-shaped) values are looked up: linear
in the plan's size. Same rewrite and same errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Failing test: bind() rewrote node by node through bind_json, which prepared
the slot (placeholders and values to JSON, their hash sets) for every node:
~2.4 s per bound query on the x10 plan (491 nodes, 5000 placeholders).
PreparedSlot is the seam; its stub still prepares per call.

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

bind() went through bind_json per node, which converted the slot's
placeholders and values to JSON and hashed them again for each of the
plan's nodes: ~2.4 s per bound query on the x10 plan (491 nodes, 5000
placeholders). PreparedSlot prepares a slot once; bind() rewrites each node
with it, then the plan's other fields (edges, roots) rather than walking the
nodes a second time. Binding the x10 plan (copy, rewrite, deserialize) now
takes ~110 ms.

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

Failing test first: every public workload plan (no KLL) stores
byte-identical view files whether a refresh group's views that share no
node below them run as one run or apart, and some plans run a group in
several parts (asap_precompute_window_view_parts above 1). Adds the
--precompute-split-views option (EngineOptions::precompute_split_views,
default true), not read yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refresh group's views that share no node below them (views over
different tables, say) are compiled as separate parts; a window runs its
parts at once, one thread each (the first on the precompute thread), so it
commits after its slowest part rather than after all of them. The stored
rows are the same (byte-identical view files over the public workloads).
The parts' CPU counts as the precompute thread's phase CPU. On by default;
--precompute-split-views false runs each window whole. The
asap_precompute_window_view_parts gauge reports the parts per group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A window's parts other than the first run on threads named
precompute-part, so per-thread CPU sampling counts them as precompute; a
part thread that cannot start fails the window.

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 labels Dec 4, 2026
@zzylol
zzylol merged commit c58ee18 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant