Conversation
zzylol
added a commit
that referenced
this pull request
Oct 4, 2026
Example 1 declares http_requests_total a counter, so Stage 3 selects P60 at 46.201 × 0.1 = 4.620 cost per second. Update the per-second ranking test and the Stage 3 cost model's worked example to P60. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
Oct 4, 2026
zzylol
added a commit
that referenced
this pull request
Oct 4, 2026
This was referenced Oct 4, 2026
Draft
Share one UnivMon across distinct, L2 and entropy; document why those readouts stay uncertified
#596
Draft
…ibration
Stage 3 prices every candidate in cost per second of wall time:
- an ingestion-time node over one second of ingested rows (λ: declared
ingestion rate, else cardinality / ingestion interval, else the default);
- a query-time node per evaluation times the evaluation rate of the roots
reaching it: distinct repeat intervals add, equal intervals count once,
one-off and unknown recurrence is amortized over the horizon H (1 h);
- ingestion-time state read at query time costs w_mem × retained bytes
(2 windows × groups × state bytes), w_mem = 1.25e-7 cost/(byte·s).
The coefficients and H move into Stage3Calibration on PlanningModels
(with_calibration). plan_stages and the selection API take a per-root
RootDemand (accuracy, recurrence, predictability), filled from workload
entries by the facade and the stage_pipeline devtool. COST_UNIT becomes
COST_PER_SECOND ("cost_per_second") and the cost source names the
calibration version.
Also fixes scan pricing found by the Example 3 acceptance work: a scan's
rows follow the longest range plus offset reading it (not 1 min), and a
time range passes only its own span, so a shared 5-year scan is no longer
costlier than separate scans.
Example 1 still selects P58: 52.201 per evaluation becomes 5.220 per
second; every candidate scales by 0.1, so the ranking is unchanged. The
Example 1 viewer fixture is regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scope of the Stage 3 planning model for designers: what is priced, the per-second basis for ingestion-time and query-time nodes, recurrence and horizon, the memory term (1.25e-7 cost/(byte·s), 1 GB ≈ 1/8 vCPU) and its configuration, illustrative default statistics, interaction with the tree DP and shared nodes (one node, one computation; "not materialized" is Stage 2 duplicating the node), a worked Example 1 table, and what is out of scope. Linked from the proposals README and #509 Stage 3. The Example 1 acceptance doc's costs are restated per second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
stack/509-e2-keyed-additive-topk
branch
from
October 5, 2026 06:21
6575cfe to
4bcdab4
Compare
zzylol
force-pushed
the
stack/509-w1-stage3-cost
branch
from
October 5, 2026 06:21
8764a6b to
3ee0baf
Compare
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.
Rebased on main d4869a7 (DF 54).
Wave 1 chain: #594 → #593 → #592 → #591 → #595 → #596 → #597 → #598 → #599 (on #589)
Why
Stage 3 priced each candidate per workload evaluation, which can't compare ingestion-time work (it runs as data arrives) with query-time work (it runs on each evaluation), or one-off queries with repeating ones. Stage 2 materialization (#509, step 5) needs a common basis first. The user approved decisions S1, S2 and S5. Design doc:
docs/design_docs/proposals/stage3-cost-model.md.What
ingestion_rate, elseinput_cardinality / data_ingestion_interval, else the default. A query-time node costs its per-evaluation cost × r, where r =evaluation_rate_ofover the distinct repeat intervals of the roots reaching it. Equal intervals count once. One-off andUnknownrecurrence is amortized as invocations / H, with H = 1 h (S5).w_mem × retained bytes, withw_mem = 1.25e-7cost/(byte·s) (1 GB ≈ 1/8 vCPU). It applies only to ingestion-time state that query time reads. Retained bytes = 2 × groups × state bytes.Stage3CalibrationonPlanningModels(with_calibration) replaces the hard-coded calibration. The unit iscost_per_second(COST_UNIT→COST_PER_SECOND), and the costsourcenames the calibration version.RootDemand { accuracy, recurrence, predictability }(inasap_types::workload) replaces&[Option<AccuracyTarget>]inplan_stagesand the selection API. The facade andstage_pipelinefill it from the workload entries.How
priceincrates/plan-selection/src/lib.rsreads each node's timing from the physical DAG and finds which roots reach the node. Costs still add up node by node, so the tree DP's additivity assumption holds, and a shared node is still charged once.Before / After
cpu_ms_per_workload_evaluationcost_per_secondTests
New tests:
cargo test --workspace: 1,523 passed, 10 ignored. #589 had 1,517 passed and 10 ignored; the difference is the 6 new tests. fmt and clippy (-D warnings) pass. Viewer tests: 29 run, OK, with 6 skipped becausepy_mini_raceris missing. The Example 1 fixture is regenerated and validated bycrates/devtools/tests/stage_pipeline.rs.🤖 Generated with Claude Code