Skip to content

feat(data_plane): push precompute (design, tests T1-T19, implementation) - #854

Closed
zzylol wants to merge 10 commits into
sync/planner-main-1760a69ffrom
feat/parallel-precompute
Closed

zzylol wants to merge 10 commits into
sync/planner-main-1760a69ffrom
feat/parallel-precompute

Conversation

@zzylol

@zzylol zzylol commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Merged into #855 (feat/tiered-view-storage, merge commit 1019cc9, head 0b0b46d). The demo runs from that one branch, with push precompute as the data_plane default (--precompute-mode window keeps the window path). The demo-workload A/B is in docs/design/parallel-precompute.md, "Demo workload A/B", on that branch. This PR stays open as a draft for reference.

Design: docs/design/parallel-precompute.md.

This PR has the design, the approved tests T1–T19 and B1–B2, and the push precompute implementation (--precompute-mode push). It is stacked on #852, whose head (1a0c64cb: task pool, series-split windows) is merged in. The window path stays the default.

For reviewers

  1. data_plane/src/push.rs: shard instances, the PushStore, the install probe, seal, and the memory budget.
  2. The committer changes in engine.rs: PrecomputeJob::Push, PoolEvent::Partial and WindowTasks::push_window reuse the pool's reorder buffer, merge and barriers.
  3. Test changes after approval. These fix test bugs or align a test with the merged task pool. No assertion was weakened.
    • T5: regroups by the first label column when a scan has no job column.
    • T7: collects the rules seen.
    • T13: seals the window behind a barrier before sending the late sample, and expects 4 late samples per metric an ingestion-time view reads.
    • T14: runs one precompute thread, because the pool's slots would otherwise hold more windows than the test writes.
    • T1: takes PARITY_PUSH_SHARDS.
  4. Still ignored.
    • T9: no plan with a view over a view.
    • T5's engine-level half: a hand-written Reduce chain does not compile.
    • T16: chunked seal is not implemented. Seal is one step per window. Out of scope for this PR, as is T9.

What push does

  • Which groups are pushed. A group whose run splits by series, carries no state across windows, reads no view, and whose Scans read exactly the window (checked by a probe at install) is built by push. Other groups stay on the window path.
  • Folding on the shards. Each ingest shard (series hash) keeps one instance of the group's compiled ingestion run per open window. The instance runs over a store whose raw-data slots are streams fed inline on the shard thread. Each morsel is converted once per metric and slot schema and reaches every view of its source, with no queue and no raw buffer.
  • Seal and commit. After the flush that closes a window, every shard seals it, idle shards with an empty run. The committer concatenates the partials, using the pool's series-split merge, and commits them through the same reorder buffer, persistence and barriers.
  • Memory budget. --precompute-memory-budget-bytes is checked against the instances' run memory. While an older window is open anywhere, state may go over the budget until its seal frees it. A lone window over the budget fails alone.
  • Metrics and rules.
    • Phases precompute_push, precompute_seal (by group and shard), precompute_combine and precompute_commit.
    • Gauges asap_precompute_state_bytes, asap_precompute_open_instances and asap_window_commit_lag_seconds.
    • asap_samples_total{outcome="late_for_views"}.
    • pipelines::combine_rule(s) implement the rule table.

Results

The design doc records E1/E2 in D1, D2, D8 and D9, and has a B1/B2 section.

B1/B2 (typical 60 s / 10 Hz dashboard, 12 views, raw data not kept, K ingest shards = K precompute threads, paced at 10 Hz). Push coalesces each shard's samples into morsels of up to 32,768 samples or 1 s before folding (--push-batch-samples, --push-batch-max-ms); a seal folds what is pending first.

series, K window ready, window path / push (mean s) M samples/s, window path / push fold CPU, window path / push (s) total CPU, window path / push (s)
10k, 4 18.5 / 12.3 0.20 / 0.20 (offered) 121 / 135 234 / 235
10k, 12 14.7 / 12.3 0.20 / 0.20 (offered) 126 / 140 254 / 259
100k, 4 (2M/s offered) 224 / 193 0.78 / 0.86 1,436 / 1,523 1,870 / 2,028
100k, 12 (2M/s offered) 88.6 / 44.7 1.33 / 1.59 1,422 / 1,312 1,926 / 1,693
  • Latency. Push commits each window at the 15 s lateness bound at 10k series, whatever K is. At 100k series and K = 12 it halves the window path's latency.
  • CPU, 10k series. Before batching, push used about 1.75× the window path's fold CPU when paced. With batching it uses 1.1×, and total CPU matches.
  • CPU, 100k series and K = 12. Push uses 8% less fold CPU and 12% less total CPU than the window path.
  • Default. Push stays opt-in.

Core scaling

Setup.

  • The engine host has 28 physical cores and 56 logical CPUs. The engine is pinned to CPUs 0..K: physical cores first, then SMT siblings.
  • Senders run on a second host over 10 GbE (iperf3: 9.42 Gbit/s, RTT 0.06 ms) and back off exponentially on 503.
  • Workload: the dashboard plan with 200k series. Throughput is measured at saturation over 145 s.
K push M samples/s (efficiency vs K = 12) window path M samples/s
4 0.89 (0.82) 0.46
12 3.25 (1.00) 0.21
16 4.41 (1.02) 0.17
28 physical 6.59 (0.87) 0.13
32 (+SMT) 6.56 (0.76) 0.12
48 (+SMT) 8.00 (0.62) 0.10
56 (+SMT) 8.59 (0.57) 0.09

Push.

  • Scaling. Close to linear up to the 28 physical cores. SMT siblings add about 30%.
  • The knee. It is the single ingest coordinator, not the fold or the committer. Its CPU grows with the request rate. Shard queues are counted out only when it applies a report, so Remote Write gets 503s while engine cores are still idle.
  • Request size. With larger requests (12 senders), push takes 8.69M samples/s at K = 28 with no 503.
  • Profile. Most engine CPU goes to Remote Write decode, with series interning the top symbol.
  • Latency. At 1M samples/s offered, push commits each window 16.8 s after its end at K = 12, 28 and 56 (15 s lateness + < 2 s).

Window path (with --precompute-threads K).

  • With 48 small-request senders it does not scale, and it cannot sustain even 1M samples/s.
  • Its coordinator is saturated. It drops and rebuilds raw pane maps, and the shards clone those maps on every append (copy-on-write).
  • With fewer, larger requests it reaches 0.51M samples/s at K = 28.

The full tables are in the design doc's B section.

Verification

  • cargo test -p data_plane: every test passes.
    • push_precompute: 15 passed, 3 ignored (T9 and T16 are out of scope for this PR).
    • precompute_pool, ingest_shards, planner_executor_parity (T1, T2) and the rest: all pass.
  • Parity of push against the Planner executor (T1) and of stored view rows (T2): pass at K = 1, 4, 8, 12 (PARITY_PUSH_SHARDS).
  • Window-path parity: passes at K = 1, 4, 8, 12 ingest shards and precompute threads.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9

@zzylol zzylol added documentation Improvements or additions to documentation area: data plane Runtime ingestion, storage, and query-serving data paths labels Nov 20, 2026
Design and test plan for computing ingestion-time views on every ingest
shard: refresh groups compiled into push pipelines split at pipeline
breakers, one instance per (shard, window), partial outputs combined at
window close by a rule derived from the plan (concatenate per-series
states, merge mergeable states, single partition otherwise), commits in
window order. Implementation follows after the test plan is approved.
…st plan

Records each decision with options, precedents (push and streaming
engines), corpus evidence (what the Planner puts at ingestion time over
3,731 public queries) and conclusion, with result slots for E1-E5.
Rebased on the sharded ingestion: seal travels with the coordinator's
flush, combine runs on the window-task pool, views of a source run
inline on the shard thread, non-mergeable breakers are a list awaiting
ordered-merge. Test plan revised to T1-T19 and B1-B2.
@zzylol
zzylol force-pushed the feat/parallel-precompute branch from 38a73a7 to 27ae132 Compare November 21, 2026 00:11
…ng until implemented)

Tests from the approved test plan of docs/design/parallel-precompute.md,
written before the implementation:

- T1, T2 in planner_executor_parity.rs: push answers and stored view rows
  against the reference and the window path, K = 1, 2, 4, 8.
- T3-T19 in push_precompute.rs. Each runs its fixture in window mode
  first, then in push mode.
- B1/B2: ingest_bench takes PRECOMPUTE_MODE=push and, when paced,
  reports the newest window's commit lag.

Interface only, no push logic: EngineOptions.precompute_mode
(--precompute-mode, refused at install when push),
precompute_memory_budget_bytes, the test hooks slow_refreshes (the same
shape as the precompute task pool's) and panic_in_combine_of_window_end_ms,
pipelines::{CombineRule, BreakerRule, combine_rule, combine_rules}
(returning "not implemented"), and Snapshot::view_rows for comparing stored
views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9
zzylol and others added 4 commits November 21, 2026 10:06
Takes the precompute task pool, series-split windows and SlowRefresh
hooks; the test hook slow_refreshes is the pool's, the duplicate field
from the test commit is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9
…w pipeline instances

--precompute-mode push (docs/design/parallel-precompute.md, D1-D9):

- Push groups. A refresh group whose run splits by series, carries no
  state across windows and reads no view is built by push, once an
  install probe shows that its Scans read exactly the window. Other
  groups keep the window path on the precompute task pool.
- Instances. Each ingest shard (series hash, D3) keeps one instance of
  the group's compiled ingestion run per open window. The instance runs
  over a PushStore whose raw-data slots are streams fed inline on the
  shard thread. One morsel is converted once per slot and reaches every
  view of its source with no queue and no raw buffer (D2). The run's
  non-Send future lives in the shard's LocalPool.
- Seal and commit. After the flush that closes a window, the
  coordinator sends Seal to every shard. Each shard ends its streams
  and sends its partial (idle shards an empty one). The committer
  combines the partials with the series-split merge of the task pool
  (Concatenate) and commits them through the same reorder buffer,
  barriers and persistence.
- Raw data. Metrics read only by push groups keep no raw data, and push
  groups no longer hold raw-data cutoffs back.
- Memory budget (--precompute-memory-budget-bytes). Open state is the
  instances' run memory. A window fails only when it is the only one
  open on every shard and still over the budget. While an older window
  is open anywhere, the state is allowed over the budget until the
  seal frees it.
- Hooks. slow_refreshes delays a pushed window's combine, and
  panic_in_combine_of_window_end_ms makes it panic. The panic is caught
  and fails that window only.
- Metrics:
  - asap_phase_* {phase="precompute_push|precompute_seal", group,
    shard}, precompute_combine {group} and precompute_commit;
  - asap_precompute_state_bytes, asap_precompute_open_instances and
    asap_window_commit_lag_seconds;
  - asap_samples_total{outcome="late_for_views"}, counted at routing in
    either mode.
- pipelines::combine_rule(s) implement the rule table. Every node is
  checked before the groups are read, so an unknown breaker is named.

Test fixes, keeping each test's stated intent:

- T5 regroups by the series' first label column when a scan has no
  `job` column.
- T7 collects the rules seen, rather than keying them by a payload prefix.
- T13 seals the window behind a barrier before sending the late sample,
  and expects 4 late samples per metric that an ingestion-time view
  reads.
- T14 runs one precompute thread, because the task pool's slots would
  otherwise hold more windows than the test writes.
- T1 takes PARITY_PUSH_SHARDS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9
…schema

Every Scan of every open window that reads a metric in one schema now
shares one conversion of the morsel, as the window path shares a chunk's
conversion through RawReads. The executor re-applies each slot's time
range and predicates.

Measured at 10k series × 2 metrics, 10 samples/s, 4 shards, unpaced:
push folding fell from about 1.75× the window path's precompute CPU to
the same (122 s against 123 s for 60M samples).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9
@zzylol zzylol changed the title docs(data-plane): design parallel precompute (push pipelines) feat(data_plane): push precompute (design, tests T1-T19, implementation) Nov 21, 2026
zzylol and others added 3 commits November 21, 2026 16:49
…fore folding

Each fold runs every view of the group, so a 10 Hz scrape's share of a
shard (a few thousand rows) costs more per sample than a large morsel.
A shard now buffers its routed samples and folds them once
--push-batch-samples are pending (default 32,768) or the oldest is
--push-batch-max-ms old (default 1,000). A seal folds what is pending
first, so batching never delays a window's commit. A fold gives each
window's instance a morsel of its own samples only, so a large window
does not cost a small window's run its memory.

T15 folds every request as it comes (MorselBatching 0), because it
measures open state request by request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9
…ite load generator

examples/remote_write_load.rs sends Remote Write from another host:
- per-series protobuf prefixes are encoded once;
- each thread keeps one keep-alive connection;
- the sender is paced to the wall clock or stamps samples in the past;
- 503s get an exponential backoff.

The design doc's B section records the sweep over K = 4–56 CPUs (28 physical cores
plus SMT points), window-ready latency, request-size checks and where each mode
stops scaling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo6sg4cEjJJhktNtL9
zzylol added a commit that referenced this pull request Nov 22, 2026
…requests

In window mode the single ingest coordinator was the bottleneck under
many small Remote Write requests: the #854 sweep measured 0.1-0.5M
samples/s, falling as shards were added, with the coordinator thread
busy. Every request reached every shard; each shard reported each batch
with a clone of its raw data, each report started a coordinator pass
with a flush of every shard, each eviction message produced another
report (another pass), and because the coordinator's snapshot shared the
shards' raw data, every append copied the shard's pane lists.

- A shard drains every batch already queued to it and sends one report
  (sample times, counts, first samples): one report, and at most one
  pass, per drained queue instead of per request.
- Reports no longer carry raw data. A shard sends its raw data only with
  its answer to a flush (Command::Flushed(shard, raw_data)), which is
  what the windows closing behind that flush read.
- Eviction (Maintain) sends no report, so it starts no pass.
- When no query reads raw samples (no query-time Scan), the coordinator
  publishes no raw data and lets each pass's snapshot go once its closed
  windows are queued: a shard's next append owns its raw data again
  instead of copying its pane lists (only queued refreshes hold them
  until they run). Ingestion::queries_read_raw_data says which.

Measured on two 40-vCPU hosts (engine pinned to 40 cores with 32 ingest
and 32 precompute threads; 12 sender processes x 4 threads on the other
host; the 10 Hz dashboard plan, 2 x 100,000 series):
- as fast as accepted: 0.16M samples/s before (coordinator 1.00 core)
  -> 8.02M after (coordinator 0.45 core, engine 39.7 cores);
- paced at the wall clock, 3M and 4M samples/s offered (2 x 150,000 and
  2 x 200,000 series): every sample accepted, none late; engine 24.9
  and 26.3 cores, coordinator 0.86 and 0.83.

Parity: 384/384 queries and 324/324 range steps at 1, 4 and 8 shards;
ingest_shards, window_levels, view_tiering and the other suites pass.
precompute_pool's byte-identity test at 12 threads fails intermittently
under load with and without this change (1 of 3 runs on 8368fcf).
zzylol added a commit that referenced this pull request Nov 23, 2026
Push precompute now commits into tiered view storage and keeps the demo
branch's behaviour: windows from the stream start, the drained shard
queues and flush-carried raw data of the coordinator, multi-level window
chains (groups reading other groups stay on the window path), allowed
lateness and backpressure.

- engine.rs: both option sets; a shard drains its queue, appends, and
  folds each batch into its push instances in the same pass; Seal is
  handled in order with samples.
- store.rs: ViewStore::rows reads each window through its slot (pending,
  cached or decoded from its fragment).
- planner_executor_parity.rs: data_plane_over takes the view mode; T1 for
  push runs with every view read cold from the view files.
@zzylol

zzylol commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Landed on main via #855 → #864 (squash 910ecbc): push precompute is the data_plane default there. The branch feat/parallel-precompute is kept.

@zzylol zzylol closed this Nov 24, 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 documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant