feat(optimizer): select atomic costs by observed data shape - #726
Open
zzylol wants to merge 1 commit into
Open
Conversation
milindsrivastava1997
approved these changes
Sep 10, 2026
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
ASAPQuery's optimizer could load atomic sketch costs only by exact workload JSON. Evaluation and offline planning need the same bounded cardinality/skew profile-selection semantics used by the ERP production path.
What
{cardinality, zipf_exponent, benchmark_events}shape to atomic-cost profiles.asap-optimizer-cliandcandidate-gen-dump.How
The selector uses the maximum normalized log2-cardinality and Zipf-exponent distance. Uniform and Zipf profiles never cross-match. The selected table continues through the existing exact
(sketch, params)atomic-cost resolver.Before this PR
Offline ASAPQuery optimization required an exact serialized workload selector and could not consume a runtime-observed data shape.
After this PR
Offline ASAPQuery evaluation can choose the same nearest benchmark scenario as the production ERP policy, then optimize over measured sketch costs.
Verification
CARGO_NET_GIT_FETCH_WITH_CLI=true cargo test -p asap_planner optimizer::atomic_costs::tests— 16 passed.Relationship to ASAPQuery-backend PR #581
Both PRs implement the same policy purpose: configure sketches from the closest sufficiently measured data shape. #581 is the production runtime-observation and ASAPPlanner path; this PR is the ASAPQuery offline optimizer/evaluation path. They share shape fields and distance semantics but are not a direct runtime call chain.
Limitations and follow-up
The CLI currently receives observed shape as a JSON artifact; live observation belongs to backend #581. A shared wire crate would remove the duplicated Rust shape types.