Repository navigation
Cost calibration: a deployment's measured cost file, per-series scans, priced predicates, raw rows in memory, groups a window reaches - #1555
Draft
zzylol wants to merge 18 commits into
Conversation
zzylol
force-pushed
the
feat/sil-inlist-selectivity
branch
from
December 3, 2026 19:28
01ff90c to
0673ed1
Compare
…med scan/filter constants, raw rows in memory and active groups per window
Test-first phase of the cost calibration (items 2-5 of the calibration
proposal; item 1's cost file and the e2e tests follow in their own commit):
- T2: a measured Scan entry's `ns_per_series` charges each series the scan
visits (10 min of `auth`: 6,000,000 rows x 41 ns + 100,000 series x
8,700 ns = 1,116 ms); a negative one is refused.
- item 3: a scan charges `ScanOperationsPerRow` per row read and its
predicates `FilterOperationsPerRow` + `FilterOperationsPerRowPerComparedValue`
per value compared; a Filter the same (reference executor: 1 + 2.4 ns
per compared value per row). U1's last assertion now expects the
IN-list's compared values on top of a TRUE filter.
- T5: `raw_data_medium` Memory charges a query-time scan's retained raw
rows as memory at `raw_data_bytes_per_row`, none on disk, objective =
plan_cost.
- T6: a chain emits and keeps states only for the groups its windows
reach (100,000 rows over 100,000 groups: 63,212 per window); a dense
chain is unchanged.
Signatures only, behaviour kept: `OperatorCost::ns_per_series`,
`UnitPrice::ns_per_series`, `DataPlaneExecution::{raw_data_medium,
raw_data_bytes_per_row}`, `CostConstant::{ScanOperationsPerRow,
FilterOperationsPerRow, FilterOperationsPerRowPerComparedValue}` and their
`operations_per_unit` constants are added but not read yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…t's measured cost file T1, T3, T4 of the cost calibration over three SIL intents whose runs were measured on one machine (fixtures: SIL text, tables, data facts): - T1: each measured cost file validates; the slower machine's is the measured machine's at 1.25x (every measured time and the formula scale); every node whose operator the file measures is priced from it. - T3: binding-free queries (drill_cnt q1, dash q1, rca q1) predicted within 1.5x of their measured medians; full intent keeps dash's and rca's shared state and predicts its upkeep within 1.5x of measured. - T4 (ignored): drill_cnt keeps the lightcone once a top-k binding is costed at its heavy values' rows (needs item 6, IN-list branch). The cost files themselves come with item 1's commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
… (ns_per_series) Item 2 of the cost calibration. A deployment whose store keeps raw rows by series pays per series a scan finds and decodes, beside per row: `OperatorCost::ns_per_series` (default 0) is charged per series visited, each series its sources declare and at most one per row read. Validated like every other price; summed over an aggregate's measure entries. Example (T2): 10 min of `auth`, 6,000,000 rows, at 41 ns per row and 8,700 ns per series: 1,116 ms over 100,000 series, 333 ms over 10,000 (246 ms per row alone). The test's 10,000-series data now keeps the source's 10,000 rows per second (sample interval 1 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
… compared value Item 3 of the cost calibration. The abstract 1-operation-per-row charges of a scan and a filter become named, measured constants: - `SCAN_OPERATIONS_PER_ROW` (1): the reference executor's in-memory store hands batches on whole, 0.2-1.9 ns per row (batches of 10,000 to 1,000 rows, 1,000 to 100,000 series: no per-series cost there; a deployment's per-series cost comes from its measured file). - `FILTER_OPERATIONS_PER_ROW` (1) and `FILTER_OPERATIONS_PER_ROW_PER_COMPARED_VALUE` (2.4): a filter, and now a scan's predicates too (charged 0 before), per row read and per value each row is compared with. Measured: IN-list of 1 / 10 / 100 values 3.5 / 25.7 / 244 ns per row (2,000,000 rows in batches of 10,000). `compared_values` counts an IN-list's values, one per comparison, null test or subquery membership, summed over AND/OR; a literal compares nothing, so a `TRUE` filter costs what it did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…lane keeps them Item 4 of the cost calibration. `DataPlaneExecution::raw_data_medium` (default `Disk`) says where the data plane keeps the raw rows its query-time scans read, and `raw_data_bytes_per_row` (default `None`: the decoded width) what one row takes there, as measured. In memory they are charged as memory (average and peak, memory byte cost) instead of disk, in `plan_cost` and in Stage 3 alike: `raw_data_disk_cost_per_second` is renamed `raw_data_cost_per_second` and prices by the medium; Stage 3's peak-memory and disk quantities take the raw part by the medium. T5, revised: the scanning plan of `count_over_time(m[1m])` every minute keeps 60,000 rows, 1,920,000 bytes, on disk by default and in memory for the in-memory deployment (none on disk). At the memory price that scan is no longer the cheapest, so the test costs the default-selected scanning plan for both deployments and checks that Stage 3 then selects a plan keeping no raw data, its objective equal to its plan_cost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…he groups its rows reach Item 5 of the cost calibration. A tumbling-window chain was charged a state per group in every window, emitted and kept, though a window holds a state only for the groups its rows reach. Now each window holds `expected_distinct_values(rows per window, groups)` of them (rows spread uniformly over the groups): the chain's emitted states, its windows' memory (sealed, open, cached) and a `SummaryMergeWindows`' merged and emitted states and memory scale by that share. Dense chains are unchanged (10,000 rows over 1,000 series reach all but 0.005%). Example (T6): `auth`'s 10 s windows hold 100,000 rows over 100,000 (host, user) groups, 63,212 reached: 6,321.2 states emitted per second, not 10,000, and 61 windows of 63,212 states kept. Rows are assumed uniform over the groups; a declared skew (with item 6) would lower it further (about 25,000 under the measured Zipf data). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
Item 1 of the cost calibration: the deployment's measured costs as data, supplied through `CostInputs` (no planner constant changes). `calibration/measured-cost-files/<machine key>.json` is a CostInputs file: - measured_operation_costs: query-time Scan 41 ns per row + 8,700 ns per series (TimeRange inside it), ingestion-time Scan 150 ns per arriving row, chain updates and window closes, merges (200 ns per exact state, 1,200 per DDSketch state), finalize 300 ns per group, DDSketch estimate, ns_per_ingested_sample 460; - data_plane_execution: the data plane's view window cache (60 s idle, 15-minute files) and raw rows kept in memory at 32 bytes per row; - frozen_calibration_factor 1.0. Fitted on 2026-12-03 from 60-round runs of three SIL intents in three planning modes on one machine (README: each entry's data points). The second machine's file is the same table at 1.25x (measured 1.22-1.28x in every operator class), the formula-priced nodes scaled 1.25x too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
Values pinned on today's costs that the cost calibration changes, each explained: - U13 (IN-list anchor): an undeclared IN-list still keeps every row; its filter and scan now cost that plus evaluating it (100,000 x 10 compared values; a scan's 6,000,000 rows x (1 + 10 x 2.4)). - E6 (IN-list anchor): today's drill_cnt costs 177.9132 / 169.2572 / 140.9361 become 192.9132 / 149.6450 / 125.8274: q2's scan evaluates its 10-value IN-list on its 6,000,000 rows (+15.0/s); a chain over `auth` keeps and emits states only for the 63% of groups its windows reach. - lowest_mean_latency pins: distinct-two-forms 36.7112 -> 36.4823 ms (10,000 series at 15 s: a 10 s window reaches 49% of them, fewer states to emit in the refresh), seed-862 709.8367 -> 709.8338, typical dashboard 847.2063 -> 847.0459 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…es too With the measured scan prices the planner may build a summary chain at query time (dash q2 in query-at-a-time mode); the files measured chains only at ingestion, leaving that node on the formulas. Add query-time chain entries at the same per-row update (exact 55 ns, DDSketch 116 ns; 1.25x on the slower machine), so every node of the measured intents whose operator the files measure is priced from them (T1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
… test clippy::wildcard_enum_match_arm (denied in usage/mod.rs) on item 2's match, and rustfmt on the measured cost file test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
… whose costs items 3 and 5 move
No selected plan changes: every difference is a cost, CPU, memory or detail
number of the same DAG.
- o11y_bench q02, q05, q06, q12, q18, q19, q21, q22, q23, q25: each scan's
label matcher (e.g. `{job="order-service"}`) is now evaluated per row
read (1 + 2.4 operations per compared value), e.g. q12's scan 5.9 ->
9.4 us per evaluation, cost 0.5572 -> 0.5607 per second.
- sketch plans chains-10m-5m-3m-10s-mvp, distinct-over-time-5pct-raw-retained,
random-mixed-seed-862-long-w01-q3-mvp, seed-862-w01-q3-q8-mvp and
seed-862-w02-q2-q7-mvp: a chain's window emits and keeps states only for
the groups its rows reach, e.g. 667 rows per 10 s window over 10,000
series reach 4,866 of them: 486.6 states emitted per second, not 1,000.
Regenerated with UPDATE_SNAPSHOTS=1 (release, --ignored).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
… only the series its predicates select Item 2 on the IN-list rule: a query-time scan's series visited are the declared series times the share its label predicates keep (kept values over declared values per restricted column), at most one per row read; `a_measured_scan_visits_only_the_series_its_predicates_select` checks 100 of 100,000 series under `host IN (10 of 10,000)`. Tests that now meet the IN-list rule: the scan-predicate terms test reads every arriving row at ingestion time (query time reads the selected series' rows); U5's ingestion scan costs its predicate on every arriving row; Q5-E2's lower bound follows item 5's cheaper chain (78.37/s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
… readers see them, series only at query time Review of #1555 (important findings): - I1: a window's groups reached now follows how its rows spread (`GroupReach`): periodic series (`sample_interval` declared) reach min(1, rows/groups) - 10,000 series every 15 s in 10 s windows hold 2/3 of them, a window equal to the interval all of them; a key column with a declared Zipf skew (item 6's `zipf_exponent_per_label`) reaches Σ g(1 - e^(-rows p_i/g)) - 100,000 rows over 10,000 Zipf(1) hosts of 10 users reach 28.1% of the (host, user) groups; otherwise rows fall at random (1 - e^(-rows/groups)). - I2: the share is the chain's and window merge's output: its rows and bytes are one window's states (readers, stored files and memory see the same count); `OutputFacts::window_groups` carries every group and the reach so a window merge sizes its wider window. - I3: a measured scan's per-series charge applies only at query time, over the series its predicates select (none at ingestion). - I4: T4 runs: with the measured file and the declared host skew, drill_cnt's full intent keeps the (host, user) counts, below the on-demand plan, and the formulas alone do not keep them. The measured intents' fixtures now declare the generator's skews (hosts Zipf 1.0; services Zipf 0.8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…ted on those counts); window share scales memory, stored bytes and emits Revises I2 of the review: scaling the chain's output edge broke Stage 3's per-family folded-rows invariant and the MILP = plan_cost check. The measured SummaryMerge price was fitted against the planner's all-group state counts, so readers keep charging every group; the window's memory, stored file bytes and emitted states hold only the groups its rows reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…h too; re-pin anchors after I1 - How a window spreads its rows (`GroupReach`) is read from the node's own output key columns and its sources' facts, not its producer's schema, so a candidate costs the same in Stage 3 and plan_cost. - A window merge's wider window reaches the groups the rows of its narrower windows reach (same reach), its merged and emitted states and memory scaled by it; `OutputFacts::window_groups` is gone (unused). - With periodic series reaching every group again (I1), the anchors move back: E6 192.9132 / 169.4972 / 141.1861 (each IN-list evaluated per row read), distinct-two-forms 36.7112, seed-862 709.8367, typical dashboard 847.2063; Q5-E2 98.22/s, bound 99. - dash/rca fixtures declare no service skew: with it Stage 3's objective and plan_cost differ by 3e-6 relative in dash full intent, also with this branch's reach disabled (reported on the IN-list track). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…dic series reach rows/groups of them) Numbers only, no plan changes. Against the base, only chains-10m-5m-3m-10s still moves on item 5: 10,000 series every 15 s in 10 s windows reach 2/3 of them (6,667 states per window, not every series); the other four return to the base's numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
zzylol
force-pushed
the
feat/backend-cost-calibration
branch
from
December 4, 2026 03:30
672e7fe to
b64df3f
Compare
…and, not lightcone query indices Under cost model 1 the full intent may be planned once with its dependent queries reading kept state directly, leaving `lightcone_query_indices` empty by design. T3 and T4 now check that the full-intent plan keeps state the on-demand plan does not (more ingestion-time nodes) and costs less than it; T4 also checks that the formulas alone keep no such state. Holds with and without lightcone queries reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the eval build, rca's full intent keeps two chains: the measured q3 chain over `node_metrics` (predicted 1.5 + 4.45 + 0.78 = 6.7 ms/s, measured 7.9) and a per-(service, node) DDSketch chain over `requests` for q2 (3.0 + 6.2 + 1.5 = 10.7 ms/s), which no measured run kept. The 17.45 ms/s total compared both with the one chain's 7.9: not a model over-prediction (each node is priced from its measured entries: scan 150 ns/row, DDSketch 116 ns/row, 3.9 us per state emitted). T3 now sums the ingestion-time nodes fed by the measured tables' scans (dash: `requests`, `errors`; rca: `node_metrics`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update 2026-12-04: restacked on the IN-list branch (
dae00dc), review I1–I4, item 6 adoptedfeat/sil-inlist-selectivityatdae00dc(IN-list selectivity + item 6's declared skew). Item 2's series visited are the series a query-time scan's predicates select.GroupReachis read from the chain's own key columns and its sources' facts.sample_intervaldeclared) reach min(1, rows/groups). 10,000 series every 15 s in 10 s windows reach 2/3 of them; a window equal to the interval reaches all.zipf_exponent_per_label, item 6) reaches Σ g(1 − e^(−rows·p_i/g)). 100,000 rows over 10,000 Zipf(1) hosts of 10 users reach 28.1% of the groups.SummaryMergeprice was fitted on those all-group state counts, and scaling the output edge broke Stage 3's per-family folded-rows check. The share scales the window's memory and emitted states.chains-10m-5m-3m-10sdiffers from the base.--test planner101 (1 ignored), all pass; asap-planner-cli--test planner_cli90 pass; integration pass; corpus + sketch snapshots pass after regeneration; clippy-D warningsclean on asap-cost.Deferred
zipf_exponent_per_label: {service: 0.8}on dash's tables and the measured file, Stage 3's objective and plan_cost differ by 3e-6 relative in full intent. The difference persists with this branch's reach disabled, so it lies in the skew-share path; it is reported on the IN-list track. The fixtures declare the host skew only.raw_data_mediumapplies to query-time scans' raw data only, and the renamedisk_cost→raw_costinplan/cost.rs(review nits).Summary
drill_cntintent show the shared (host, user) counts kept at ingestion (the lightcone) costing 3.2x less than readingauthat query time: cost model 1, 61 vs 191 per second. The planner predicted 169 vs 178, a 5% margin.calibration/measured-cost-files/<machine key>.json), supplied throughCostInputs.OperatorCost::ns_per_series).DataPlaneExecution::raw_data_medium,raw_data_bytes_per_row).drill_cnt(2.9x; measured 3.1x). It keeps the lightcone in all three measured intents, each of which measured cheaper there. Its per-query and per-mode CPU predictions are within 1.5x of measured.Review guide
feat/sil-inlist-selectivity(IN-list selectivity, test-first commit01ff90c37; its implementation is in progress). This PR stacks on it, and item 6 of the calibration (the rows a top-k binding's heavy values hold) is that branch's. Restack once it lands: item 2's series visited then takes the IN-list's kept series.crates/cost/src/node/usage/mod.rs:series_visited, the Scan arm's predicate terms, the Filter arm,groups_reached_share,window_group_share.crates/cost/src/node/operations_per_unit.rs:SCAN_OPERATIONS_PER_ROW,FILTER_OPERATIONS_PER_ROW*,filter_terms_per_row,compared_values.crates/cost/src/plan/cost.rsandcrates/stage3-plan-selection/src/cost.rs: the raw data medium.calibration/measured-cost-files/(two JSON files and a README with each entry's provenance).ns_per_series: 0.0added to existingOperatorCostliterals.raw_data_disk_cost_per_second→raw_data_cost_per_second.61d79428e; each change is explained there).5a37f5334andf97953520hold the failing tests, with interface stubs. Then one commit per item (2, 3, 4, 5, 1), then the anchors, a cost-file fix, style, and snapshots.Behavior: before → after
The user plans E6's
drill_cntSIL intent: top-10 hosts by count overflows(1 h), then per-user counts overauth(10 min)WHERE host IN $Y, every 10 s. The data facts are 20,000 + 10,000 rows/s;authhas 100,000 series. Each mode is planned with and without the measured file:Cost model 1, cost per second, with CPU in ms/s:
Per query with the file: q1 33.3 ms (measured 25.2), q2 on demand 2,340 ms (1,577), q2 from the lightcone 265 ms (262). The need is MVP correctness: the planner should pick the plan the data plane runs cheaper, and the paper's E7 figure needs predictions it can plot.
Interfaces
crates/cost/src/measured.rs/// The measured CPU time of one operator kind, at one phase, for one family (stays). pub struct OperatorCost { pub operator: OperatorKind, pub phase: Option<ExecutionTiming>, pub sketch: Option<SketchParams>, pub exact: Option<ExactKind>, pub measure: Option<String>, pub ns_per_unit: f64, + /// For a `Scan`: CPU ns per series it visits in one computation, beside + /// `ns_per_unit` per sample (a series store finds and decodes each series once + /// per read). Default 0; a negative or non-finite value is refused. + pub ns_per_series: f64, pub ns_per_invocation: f64, pub memory_bytes_per_state: Option<f64>, pub stored_bytes_per_state: Option<f64>, pub ns_per_state_emitted: f64, pub measured_series_count: Option<u64>, pub measures: Vec<String>, } /// A node's unit price, from its entry or interpolated between two (stays). pub struct UnitPrice { pub ns_per_unit: f64, + /// CPU ns per series a scan visits (`OperatorCost::ns_per_series`). + pub ns_per_series: f64, pub ns_per_invocation: f64, pub memory_bytes_per_state: Option<f64>, pub stored_bytes_per_state: Option<f64>, pub ns_per_state_emitted: f64, pub outside_measured_scale: bool, }crates/cost/src/model.rs/// How the deployment's data plane runs work (stays). pub struct DataPlaneExecution { pub ingest_threads: Option<u32>, pub precompute_threads: u32, pub query_threads: u32, pub allowed_lateness_ms: u64, pub max_thread_utilization: f64, pub ingest_work_at_refresh: bool, pub view_window_cache: Option<ViewWindowCache>, pub kept_query_time_results: Option<KeptQueryTimeResults>, pub answer_cache: Option<AnswerCache>, pub state_offset_bytes_per_row: u64, pub key_bytes_per_label_column: u64, + /// Where the data plane keeps the raw rows its query-time scans read: `Disk` + /// (default), charged at the disk byte cost, or `Memory`, at the memory byte cost. + pub raw_data_medium: StorageMedium, + /// The bytes one raw row takes where it is kept, as measured; `None` (default): + /// its decoded width. Not finite or not positive: refused (bad input). + pub raw_data_bytes_per_row: Option<f64>, }crates/cost/src/plan/cost.rsThe function was renamed because it no longer prices disk only.
crates/cost/src/node/cost_terms.rs/// A named per-unit constant of the cost formulas (stays). JSON: snake_case. pub enum CostConstant { + /// A row a scan reads (`SCAN_OPERATIONS_PER_ROW`, 1). + ScanOperationsPerRow, + /// A row a filter or a scan's predicates read (`FILTER_OPERATIONS_PER_ROW`, 1). + FilterOperationsPerRow, + /// A value each such row is compared with (`FILTER_OPERATIONS_PER_ROW_PER_COMPARED_VALUE`, 2.4). + FilterOperationsPerRowPerComparedValue, TimeRangeOperationsPerRow, OperationsPerGroupPerRawBatch, ChainOperationsPerArrivingRow, HashAggregateOperationsPerRow, HashAggregateOperationsPerFurtherKey, AggregateMeasureOperationsPerRow, SortOperationsPerRowPerLevel, DdsketchUpdateOperationsPerRow, KllUpdateOperationsPerRow, ExactUpdateOperationsPerRow, CounterUpdateOperationsPerRow, CarriedLabelOperationsPerRowPerLabel, KmvUpdateOperationsPerRow, KmvUpdateOperationsPerComparedHash, KmvMergeOperationsPerHash, KmvMergeOperationsPerComparedHash, ExactDistinctOperationsPerRow, ExactDistinctOperationsPerValueDoubling, ExactDistinctOperationsPerRowAtFullValueMiss, ExactDistinctOperationsPerRowAtFullPairMiss, ExactDistinctOperationsPerInsertedValue, ExactDistinctOperationsPerInsertedPair, SketchUpdateOperationsPerCounter, CounterMatrixUpdateOperationsPerCounter, UnivmonUpdateOperationsPerCounter, CmsHeapOperationsPerEstimate, CmsHeapOperationsPerEstimatedCounter, CountSketchHeapOperationsPerEstimate, CountSketchHeapOperationsPerEstimatedCounter, SketchAllocationOperationsPerCounter, ExactMergeOperationsPerState, ExtremumMergeOperationsPerState, CounterMergeOperationsPerState, DdsketchMergeOperationsPerState, KllMergeOperationsPerState, KllMergeOperationsPerInputByte, KllMergeOperationsPerMergedByte, MergeOperationsPerOutputGroup, SketchMergeOperationsPerByte, CounterMatrixMergeOperationsPerState, CounterMatrixMergeOperationsPerCounter, HeapMergeOperationsPerResidentCounter, KllEstimateOperationsPerByte, KllEstimateOperationsPerUnsortedItem, SketchEstimateOperationsPerGroup, HeapReadOperationsPerGroup, HeapReadOperationsPerResidentCounter, OutputRowOperationsPerGroup, SketchChainEmitOperationsPerState, ExactChainEmitOperationsPerState, KllMergeOperationsPerOutputGroup, }calibration/measured-cost-files/(new file format: aCostInputsJSON per machine key)Usage. The user writes the SIL intent above. They pass the data facts (
data.json:authwithseries_count100,000 at 10,000 rows/s) and the measured cost file as the deployment'sCostInputs. Everything below is checked incrates/planner/tests/measured_cost_file.rs.Inside Stage 3,
node_usage_and_cost_termsreaches each new interface:auth's q2 scan finds theScanentry: 6,000,000 rows × 41 ns + 100,000 series (series_visited) × 8,700 ns = 1,116 ms. Its IN-list is part of the measured scan time; without a file it would be charged per compared value.groups_reached_share).authas memory (raw_data_medium).The user gets back
plan.lightcone_query_indices == [2], which keeps the (host, user) counts, at cost 95.24/s against 273.79 for planning each query alone. Inreport.predicted_usage.per_query, q1 is 33.3 ms and q2 265 ms.Algorithm changes
Scan and filter CPU (item 3)
TRUE.filter_terms_per_row,compared_values): Scan = rows ×ScanOperationsPerRow+ rows × (FilterOperationsPerRow+ compared values ×FilterOperationsPerRowPerComparedValue) when it has predicates. Filter = input rows × the same filter terms. Compared values count an IN-list's values, one per comparison, null test or subquery, and sum over AND/OR.terms_reproduce_the_formula_cpu_of_every_costed_node,a_scan_charges_*,a_filter_charges_*). A predicate-free scan and aTRUEfilter cost what they did.Series visited (item 2)
ns_per_unit.ns_per_unit+ min(declared series, rows read) ×ns_per_series.Raw data medium (item 4)
raw_data_medium, sized atraw_data_bytes_per_row. The same rule applies inplan_costand in Stage 3's cost, peak-memory and disk quantities.plan_cost, that disk is 0, and that memory is +1,920,000 bytes for 60,000 rows.Groups a window reaches (item 5)
expected_distinct_values). This applies to emitted states, sealed/open/cached memory, andSummaryMergeWindows' merged and emitted states.auth; dense chains are unchanged.Decisions and open questions
Needs reviewer decision
calibration/measured-cost-files/<machine key>.json. The key is CPU architecture, model, logical cores and memory type; hostnames are never used. Alternative:tools/cost-inputs/.frozen_calibration_factor. This matches 1.22-1.28x per operator class from one run of 2 of the 3 intents, plusdrill_cnt(1.05x on its q2 scan). Alternative: wait for its own fit from the second machine's full matrix.Decided
Verification
Tests were run on a build host (
cargo test --workspace --no-fail-fast). Every failure that remains is one of the base branch's own failing IN-list tests (same names at01ff90c37).asap-costlibasap-planner --test plannermeasured_cost_file: 4 passed, 1 ignored (T4)sil_intentsS-tests fail as on baseasap-planner-cli --test planner_cliinlist_selectivityE-tests fail as on baseasap-integration-tests --test integrationasap-typeslib--ignored)cargo fmt --check,cargo clippy -D warnings(cost, stage3, planner, planner-cli, integration-tests, devtools)New tests:
End-to-end, all three intents. All modes were re-planned with and without the file and compared with measured E6 runs. Measured cost = plan-dependent CPU (precompute, persist and query threads) + raw/view memory at the cost-model-1 price, mean of 2 runs.
With the slower machine's file, the choices are the same: drill_cnt 113 vs 335, dash 11.4 vs 162, rca 256 vs 298. Measured on that machine: 74 vs 208, 14.5 vs 107, 192 vs 247.
Lightcone points, planner with the file. The base has no IN-list selectivity yet, so these use today's data-plane behaviour, where a dependent scan reads every row. The lightcone is chosen at every point:
After label pushdown and true selectivity, the analysis model with the file's constants predicts both sides of break-even: x0.1 0.20, x1 0.94, 5 min 1.75, 1 h 0.23, x10 3.68. The planner reproduces these once the IN-list branch and item 6 land.
Screenshots: not applicable.
Follow-ups
usage/mod.rs's Scan and Filter arms. Notes are in the coordination file.FILTER_OPERATIONS_PER_ROW_PER_COMPARED_VALUE.🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi