Repository navigation
fix: review nits after #745: cap message from its constant, Hydra constant weight, fallible updater, stacked shifts, viewer ranks - #752
Merged
Conversation
The five 2^n-subset caps reported a hardcoded "more than 20" through
Unsupported(&'static str). A TooManyCandidates { candidates, max }
variant formats the message from MAX_REUSE_CANDIDATES,
MAX_PANE_CANDIDATES and MAX_CAPABILITY_SHARING_MEMBERS.
Only tests built an entry from Default. They now name every field, and test_support::entry_with builds its entry explicitly.
rate(m[5m] @ 300) evaluated at 360 s reads the window ending at 360 s: counter_window skips anchored shifts and their offsets.
validate_hydra_cms refused Constant(2.0): only the unit count had a non-negative proof. NonNegativeWeightProof::PositiveConstant proves a constant greater than 0, and the shared build adds it per row (constant_weight, default 1). A non-integer or non-positive constant is refused at binding, since asap_sketchlib's Hydra adds i32 weights.
update_keyed panicked on a weighted-frequency sum past f64::MAX and UnivMon's update_single on its counter overflow. update_single and update_keyed now return Result<(), String>: the overflow is an error the caller propagates, and update_single on a keyed updater is an error instead of a debug assertion.
The per-entity summary input skipped at most one TimeShift, so TimeRange(TimeShift(TimeShift(scan))) failed with "per-entity summary requires a resolved source". below_time_shifts follows every shift and serves both this path and boundary_schema.
A rejected candidate whose cost the document carried got a rank, and a costlier one without a cost did not. Only selected and costlier rows are ranked now.
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.
Why
Review nits left after #745, decided on 2026-10-18:
validate_hydra_cmsrefused a constant weight such asConstant(2.0): only the unit count had a non-negative proof (feat(asap-physical-operators): execute HydraCms grouped counts and filtered aggregates #695/feat(dag-viewer): show the stage pipeline as three stacked lanes #698 nit).AccumulatorUpdater::update_keyedpanicked (.expect) on a weighted-frequency sum pastf64::MAX, and UnivMon'supdate_singleon its counter overflow (fix(asap-physical-operators): seed each CountSketch row independently #706 nit).QueryWorkloadEntryderivedDefault, which only tests used.TimeShiftbelow its range, soTimeRange(TimeShift(TimeShift(scan)))failed to compile (chore: fix the small nits collected from clean reviews #745 review, Low).@anchor in a counter window might be ignored (feat(planner): tumbling-pane window composition as a Pass 2 rule (Example 3) #713 nit). It is: see Counter window ignores the @ anchor (and its offset): rate(m[5m] @ 300) reads the window ending at the evaluation time #748.What
PerComputationCandidateError::TooManyCandidates { candidates, max }, whose message readsmaxfromMAX_REUSE_CANDIDATES,MAX_PANE_CANDIDATESorMAX_CAPABILITY_SHARING_MEMBERS.Constant(w)with the new proofNonNegativeWeightProof::PositiveConstantwhenwis a positive integer withini32(asap_sketchlib's Hydra addsi32weights), and addswper row. A non-positive, fractional or non-finite constant is refused at binding.AccumulatorUpdater::update_singleandupdate_keyedreturnResult<(), String>. An overflow is returned to the caller instead of panicking, andupdate_singleon a keyed updater is an error instead of a debug assertion.QueryWorkloadEntryhas noDefault. Tests name every field.boundary_schemashare one helper,below_time_shifts, which follows every stacked shift.selectedandcostlierrows.@behavior:rate(m[5m] @ 300)evaluated at 360 s reads the window ending at 360 s. The test is committed#[ignore]d, pointing at bug Counter window ignores the @ anchor (and its offset): rate(m[5m] @ 300) reads the window ending at the evaluation time #748, and this PR does not fix the bug.Not in this PR:
HHHeap::estimated_memory_bytesandWeightedFrequency::estimated_memory_bytes. Once it merges, a follow-up PR moves the pin and hasasap-plan-selection'ssummary_shapecall them.asap-plan-selectionalready depends on asap_sketchlib (it callsddsketch_indexable_bounds), so no new dependency is needed.CandidateCostkeeps its name. It holdsusage: ResourceUsageand also the pricedcost_per_second,unit,source, and aNodeCostper node. It is a priced cost, not only usage, so renaming it toCandidateUsagewould misname it.How
TooManyCandidateswith a noun phrase and its constant. The error's#[error]formats"more than {max} {candidates} (2^n Pass 2 candidates)".validate_hydra_cmsgains an arm(Constant(w), PositiveConstant), checked byhydra_constant_weight.i32toOperator::shared_summary_buildasconstant_weight, and the shared build adds it to each row when there is no weight column.Kind::SharedSummaryBuildstores it as an optionalconstant_weightfield (#[serde(default = "unit_weight", skip_serializing_if = "is_unit_weight")]), so serialized operators without the field read as a count and a unit weight is not written. This adds an optional field to the serializedSharedSummaryBuild.Ok(())or maps its kernel error. Callers in tests unwrap.below_time_shiftsis generic over the node type, so it serves both the restoredOperatorNodetree (per-entity build) and the physical node map (boundary_schema).Key code interfaces added / modified
crates/logical-asap-optimization/src/per_computation_candidates.rscrates/types/src/ir/schema/sketch.rscrates/types/src/workload/mod.rscrates/executor/src/summary_kernels/factory.rscrates/executor/src/operators/summary/mod.rs,crates/executor/src/capability.rs,crates/executor/src/physical_planner/mod.rstools/dag-viewer/stages.jsUsage, end to end: a deployment counting two requests per log line in a HydraCms state. It is checked by
positive_constant_weight_adds_the_constant_per_rowincrates/executor/tests/hydra_cms_execution.rs, which runs these steps at the head commit.And a deployment feeding a keyed state by hand (
keyed_update_overflow_is_an_error_not_a_panicincrates/executor/tests/deployment.rs):Before this PR
Constant(2.0)failed binding with "HydraCms weight must be the unit count or a non-negative weight column".After this PR
MAX_REUSE_CANDIDATES.Constant(2.0)builds and counts 2 per row.rate(m[5m] @ 300)is still wrong, tracked in Counter window ignores the @ anchor (and its offset): rate(m[5m] @ 300) reads the window ending at the evaluation time #748.Verification
Each fix started with a failing test:
a_capability_sharing_candidate_past_20_members_is_an_error,reuse_candidates_past_20_together_are_an_error(now assert the variant and the message)positive_constant_weight_adds_the_constant_per_rowkeyed_update_overflow_is_an_error_not_a_panic()has nounwrap)panes_over_stacked_time_shifts_match_single_buildtest_status_follows_the_rejection_cause_not_the_cost(new rank assertions)anchored_counter_window_ends_at_the_anchor[0.065, 0.065]vs[0.0667, 0.0667]#[ignore]until #748Tests run, each covering only the code it changes:
cargo nextest run -p asap-logical-asap-optimization -E 'test(past_20) | test(pane) | test(rollup) | test(reuse)': 12 passed.cargo nextest run -p asap-executor --test hydra_cms_execution: 9 passed.-E 'test(hydra) | test(capability) | test(shared)': 17 passed.cargo nextest run -p asap-executor --test deployment --test promql_values --test weighted_topk_binding --test precompute_population --test precompute_candidates --test summary_projection: 37 passed. Lib-E 'test(kmv) | test(factory) | test(univmon) | test(planner_parameter)': 19 passed.cargo nextest run -p asap-integration-tests --test precompute_raw_samples: 3 passed.--test tumbling_pane_merge: 10 passed, 1 ignored.--test reuse_rules --test planner_layering_example1 --test promql_to_post_asap: 49 passed.cargo nextest run -p asap-frontend-sql --test pearson_corr: 7 passed.cargo test --doc -p asap-types workload: 7 passed.python3 -m unittest test_viewer(tools/dag-viewer): 37 run, OK (4 skipped).cargo fmt --all -- --check: clean.cargo clippy --all-targets --all-features --locked -p asap-types -p asap-logical-asap-optimization -p asap-executor -p asap-integration-tests -p asap-frontend-sql -p asap-frontend-promql -- -D warnings: clean.No pinned example cost changes: this PR does not touch Stage 3 pricing.