Skip to content

perf(data_plane): judge a keyed table's field restrictions once per series per read - #910

Draft
zzylol wants to merge 2 commits into
eval/2026-12-backendfrom
perf/x4-sb-scan
Draft

zzylol wants to merge 2 commits into
eval/2026-12-backendfrom
perf/x4-sb-scan

Conversation

@zzylol

@zzylol zzylol commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem. At x4 (suite_v2 / SW c4r4h2), every round in which SB's q3 runs is late: count(DISTINCT user) … FROM login_fail WHERE src IN $SB_A over 1 h takes 11–13 s. The deployment keys login_fail by user, so src is a field. The read's label selection judged each series once, but it re-checked a series that lacks a restricted label on every chunk, by name: a series label lookup and a field lookup per restricted label, per series, per chunk. In the profile, SeriesVerdicts::keeps was 27.5% self time plus 18% memcmp.
  • Change. The verdict keeps the restricted labels a series lacks as a bitmask. Each chunk computes once which restricted labels it holds as fields, so judging a series in a chunk is one mask test. The selection is unchanged.
  • Effect. SB q3 at x4 goes from 11.9 to 10.5 s p50 (11.0 s p99). Answers are unchanged (golden check). This alone does not make the SB rounds on time: the rest of q3 is the exact distinct aggregation over the rows the IN-list keeps, plus the scan's column builds.

Review guide

  • Base: eval/2026-12-backend f13d85b (eval build 5). Read data_plane/src/store.rs: SeriesVerdicts::{field_mask, keeps} and Chunk::select_by. Check the bit-63 rule for selections of more than 63 labels.

Behavior: before → after

SB.c4r4h2 intent_full (build-4/5 plan), 1 h of history, 30 rounds at 10 s, started while the hot login_fail episode is in the 10 min window, so q3 runs in every round that runs. Data plane on 48 threads of a 56-thread host, --precompute-mode window --table-layouts layouts.json:

binary 10 s rounds ran round duration p50/max s q3 p50/p99 s q1 / q2 p50 s
build 5 (f13d85b) 15/30 12.7/13.5 11.9/12.7 0.66 / 0.13
this PR (ba11870) 15/30 11.2/11.8 10.5/11.0 0.66 / 0.14

Interfaces

data_plane/src/store.rs

 struct SeriesVerdicts {
     selection: Arc<LabelSelection>,
     by_id: std::cell::RefCell<Vec<u8>>,
+    /// By series id, for verdict 3: the restricted labels it lacks, one bit
+    /// per label in the selection's order.
+    lacks_by_id: std::cell::RefCell<Vec<u64>>,
 }
 impl SeriesVerdicts {
+    /// The restricted labels a chunk holds as fields; judged once per chunk.
+    fn field_mask(&self, is_field: impl Fn(&str) -> bool) -> u64;
-    fn keeps(&self, series: &Series, is_field: impl Fn(&str) -> bool) -> bool;
+    fn keeps(&self, series: &Series, fields: u64) -> bool;
 }

Usage (end to end): a query-time Scan of login_fail under src IN $SB_A calls RawData::read, which builds one SeriesVerdicts per read. For each chunk in the time range, Chunk::select_by computes field_mask (src is a field), keeps each series by keeps(series, fields), and cuts the rows whose src dictionary entry is allowed. The executor then aggregates the kept rows.

Tests

  • data_plane store:: unit tests: 22 passed. The new field_restrictions_on_many_series_match_a_plain_filter (2,000 series over 6 panes, field-only, key-and-field and key-only restrictions) passes before and after the change. label_pushdown_ingestion passes.
  • Golden (suite_v2.c1r1h2, 15 rounds, build 5 vs this PR): 896 of 896 query evaluations identical (620 answered).

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6bpWvKMxYBvtAgpDYGp

zzylol and others added 2 commits December 5, 2026 00:54
…ilter

Guard for judging a keyed table's field restriction once per series per
read rather than once per series per chunk: 2,000 series over 6 panes,
field-only, key-and-field and key-only restrictions, with and without the
read cache, equal a plain filter. Passes before and after the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bpWvKMxYBvtAgpDYGp
…elds by bitmask

A read's label selection judged each series once, but a series lacking a
restricted label (a keyed table's field, e.g. login_fail's src under
series_key [user]) was re-checked on every chunk by name: one series label
lookup and one field lookup per restricted label, per series, per chunk.
The verdict now keeps the lacking labels as a bitmask, and each chunk
computes once which restricted labels it holds as fields; a series is then
one mask test per chunk. Same selection.

SB q3 at x4 (count distinct user by target over 1 h of login_fail where
src IN $A): 11.9 -> 10.5 s p50.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bpWvKMxYBvtAgpDYGp
@zzylol zzylol added enhancement New feature or request area: data plane Runtime ingestion, storage, and query-serving data paths labels Dec 5, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant