Skip to content

feat(planner): cost candidates per (sketch_type, params) from sketch-bench's table - #547

Draft
milindsrivastava1997 wants to merge 1 commit into
mainfrom
worktree-524-asapquery-atomic-costs
Draft

feat(planner): cost candidates per (sketch_type, params) from sketch-bench's table#547
milindsrivastava1997 wants to merge 1 commit into
mainfrom
worktree-524-asapquery-atomic-costs

Conversation

@milindsrivastava1997

@milindsrivastava1997 milindsrivastava1997 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Closes #549

greedy_assign now resolves AtomicCosts per candidate instead of one flat cost applied to everything. CMS/HLL/KLL look up sketch-bench's exported table by exact (sketch, params) key; everything else (Sum, MinMax, CountMinSketchWithHeap, Hydra, ...) keeps the old flat stub, with a warn log so that's visible. Table loads at runtime via --atomic-costs (optimizer_cli, candidate-gen-dump) rather than being compiled in.

candidate-gen-dump got the same --atomic-costs flag so it prints resolved costs next to each candidate — using it against sketch-bench's real export (sketch-bench PR #92) is how we found that CMS currently loses to CountMinSketchWithHeap's stub on a Count query, because CMS's real merge_cpu_secs looks ~1000x too high next to its own insert/query numbers (same anomaly flagged in that PR's description, not yet root-caused).

Scope

This is a subset of #524, doesn't close it completely.

  • Param grid matched exactly to sketch-bench's grid, lookup by exact key, no interpolation
  • Costs are now a function of (sketch_type, params) instead of flat constants — but only for CMS/HLL/KLL
  • Table loaded at runtime from a file path, not compiled in
  • Loader is a trivial deserialize, no raw-Record math
  • "Missing entry -> drop candidate silently" — done, but only within a benchmarked family. Outside that (Sum, MinMax, CountMinSketchWithHeap, Hydra, ...) this does the opposite of Optimizer: param-aware atomic costs from sketch-bench #524's text: keeps the flat stub instead of dropping. That was a deliberate scope call (see issue discussion), not an oversight, but it is a real deviation worth a second look at merge time.
  • Not done: CountMinSketchWithHeap's analytic memory bound (heap_size · avg_key_size)

Not done:

  • CountMinSketchWithHeap's analytic memory bound (heap_size · avg_key_size).
  • The merge_cpu_secs anomaly above, and sketch-bench#14 (HLL memory bug) — both taint the table this depends on.
  • subtract_cpu_secs is absent everywhere (asap_sketchlib#69 not done), by design for now.

…524)

greedy_assign resolves AtomicCosts per candidate via resolve_atomic_costs
(CMS/HLL/KLL from the table, exact-key; everything else keeps the flat
stub, logged). Table loads at runtime from --atomic-costs. candidate-gen-dump
gained the same flag to print resolved costs alongside each candidate,
which is how the merge_cpu_secs anomaly (see sketch-bench PR #92) got found.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@milindsrivastava1997 milindsrivastava1997 changed the title Cost candidates per (sketch_type, params) from sketch-bench's table feat(planner): cost candidates per (sketch_type, params) from sketch-bench's table Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimizer: cost candidates per (sketch_type, params) via sketch-bench's atomic-cost table

1 participant