Skip to content

deps: asap_sketchlib 0.3.0 (capacity-independent top-k heap) - #183

Merged
zzylol merged 3 commits into
mainfrom
asap-sketchlib-0.3.0
Oct 7, 2026
Merged

zzylol merged 3 commits into
mainfrom
asap-sketchlib-0.3.0

Conversation

@zzylol

@zzylol zzylol commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Why

In asap_sketchlib 0.2.2, HHHeap::update rebuilt its key index after every accepted update. That made CMSHeap/CSHeap inserts O(k) in the heap capacity. 0.3.0 (asap_sketchlib#107) patches the index through each sift, so inserts no longer depend on capacity. Since #182 sizes top-k heaps to m·k, the 0.2.2 cost grew with every merged window and would have dominated the top-k cost table.

CMSHeap 3×256 FastPath, 1e6 Zipf(1.1) inserts over 1e4 keys, measured on clnode138:

heap 0.2.2 0.3.0
32 537 K/s 12.4 M/s
128 123 K/s 12.2 M/s
512 26 K/s 11.8 M/s
2048 5 K/s 10.7 M/s

What

  • Pin asap_sketchlib = 0.3.0 (aqpbm-planeval already used it).
  • Hydra wrappers, adapted only so they compile. 0.3.0 fixes a grid's key columns at construction (with_schema) and queries positionally (&[Option<&str>]).
    • build_hydra_* take the stream's label-column count (its first record's), and new_hydra builds the schema once.
    • update keeps every ;-joined label in its column, empty labels included.
    • query constrains the probe's leading columns (the scored subpopulations group by column 0) and leaves the rest open.
    • A record or probe of another width is refused, naming the variant and both widths. A zero label count is a BuildError.
  • DDSketch::merge now returns a Result; the wrappers expect it.
  • Top-k memory now counts what 0.3's HHHeap holds per resident, via one helper aqpbm_core::hh_heap_bytes(capacity, size_of::<HHItem>()): capacity · (HHItem + 8 B digest) + hash_buckets(capacity) · 33 B, where hash_buckets is the next power of two of ⌈capacity/7⌉·8 and each bucket holds a u64 digest, a SmallVec<[usize; 2]> and a control byte. Used by cms_heap, cs_heap, UnivMon and aqpbm-planeval (which adds string keys' own bytes).
  • aqpbm-planeval takes the workspace asap_sketchlib.
  • A Hydra stream whose records have different label widths is a BuildError naming the variant and both widths.

Known behavior changes (Hydra, not measured in the optimizer)

  • 0.3.0 Hydra keys subpopulations by column. The Polars subpopulation baselines still match an equal value in any label column, so the two differ when label columns share a value domain.
  • 0.3.0's query_key also queries the empty template on every probe, so Hydra's query cost changes.
  • Hydra's cost and accuracy rows need re-measuring before anyone uses them again.
  • A label containing ; splits into extra columns, and the record is refused.
  • Probes fill the leading columns, so group_columns other than 0 would be misread.
  • Splitting each record into labels happens inside the timed insert.
  • Hydra-UnivMon's footprint still counts its cell heaps as HHItems only.

Verification

  • Workspace cargo clippy --all-targets -D warnings and cargo fmt --check are clean.
  • cargo test passes for sketch-bench (92), aqpbm-core (94), aqpbm-cli, rqe-optimizer (74) and aqpbm-datagen (40), including the Hydra wrappers' own tests and new ones for a record of another width and an empty label.
  • The Python tests (test_study_saturation, test_export_autosketch_eval_table) pass.

Follow-up

Rerun study_saturation.py --phase optimizer-cost on an idle machine to price top-k at heaps 32/128/512/2048 on 0.3.0.

🤖 Generated with Claude Code

zzylol and others added 3 commits October 7, 2026 20:36
asap_sketchlib 0.2.2's HHHeap rebuilt its key index after every accepted
update, so CMSHeap/CSHeap inserts cost O(k) in the heap capacity; 0.3.0
(asap_sketchlib#107) patches the index through each sift. With #182
sizing top-k heaps to m·k, the 0.2.2 cost grew with every merged window.

- Pin asap_sketchlib 0.3.0 (aqpbm-planeval already used it).
- Hydra: 0.3.0 fixes a grid's key columns at construction (with_schema)
  and queries positionally. hydra_shared's new_hydra/update/query/merge
  set the schema from the first record (one column per ';'-joined label),
  constrain the probe's leading label columns (the scored subpopulations
  group by column 0) and skip shards that saw no record. A probe now
  matches its column only, not an equal value in another label column.
- DDSketch::merge now returns a Result; the wrappers expect it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
From the first review of #183:
- build_hydra_* take the stream's label-column count (its first record's,
  label_columns) and new_hydra builds the schema once. The placeholder
  schema, the rebuild on the first update and the clone-on-empty merge
  are gone; grids built from one ParamSet and stream merge as before.
- A record keeps an empty label in its own column (no dropped segments
  shifting the rest). A record or probe of another width is refused,
  naming the variant and both widths, instead of being resized.
- A zero label-column count is a BuildError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
…idth checked at build

From the second review of #183:
- aqpbm_core::hh_heap_bytes(capacity, item_bytes): what 0.3's HHHeap
  holds per resident, the HHItem, its u64 digest (slots) and its share of
  the position index (hashbrown buckets at 7/8 load, power of two, each a
  u64 digest, a SmallVec<[usize; 2]> and a control byte). cms_heap,
  cs_heap, UnivMon and aqpbm-planeval use it in place of heap x HHItem.
- aqpbm-planeval takes the workspace asap_sketchlib; stale 0.2.2 notes
  fixed (planeval Cargo.toml, hydra_kll).
- build_hydra_* check every record's label width and return a BuildError
  naming the variant and both widths; the in-closure panic is a backstop.
- polars_shared says its baseline keeps 0.2.2's any-column subset keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
@zzylol
zzylol merged commit 5deb27a into main Oct 7, 2026
2 checks passed
@zzylol

zzylol commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

@milindsrivastava1997 FYI

zzylol added a commit that referenced this pull request Oct 7, 2026
… in the planning flow

From review on #181:
- skew_summary.csv's kind, weight and range columns, and how ranges map onto
  data_shape (keyed by grouping: the worst case over its RAQEs' ranges).
- A 'Fanning out over machines' section and scripts/merge_study_parts.py,
  which concatenates per-machine run directories, refusing a point in two
  parts.
- Brought up to date: top-k needs no merge curves (heap m·k, #182), the
  guarantee fallback is merged (#180), main is through #183.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
zzylol added a commit that referenced this pull request Oct 11, 2026
…181)

* docs: end-to-end planning flow from traces to an rqe-optimizer plan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: kind/weight/range and data_shape, fanning out, and #180/#182/#183 in the planning flow

From review on #181:
- skew_summary.csv's kind, weight and range columns, and how ranges map onto
  data_shape (keyed by grouping: the worst case over its RAQEs' ranges).
- A 'Fanning out over machines' section and scripts/merge_study_parts.py,
  which concatenates per-machine run directories, refusing a point in two
  parts.
- Brought up to date: top-k needs no merge curves (heap m·k, #182), the
  guarantee fallback is merged (#180), main is through #183.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
GordonYuanyc added a commit that referenced this pull request Oct 23, 2026
Brings phase2-ver3 up to main at a3753f2 (#226). The repository
squash-merges pull requests, so main is unchanged and this branch lands
as one commit.

Conflicts and how they were resolved:

- aqpbm-datagen: the branch moved the crate's tests out of lib.rs into
  the modules they test and replaced mix_connected_bits with
  splitmix64::finalize; main added child_of, fan_out, scale_by and
  scale_range (#197), the Pareto distribution and their tests in lib.rs.
  The moved tests stay in their modules. lib.rs keeps only the 17 tests
  and helpers main added, all of them, and imports the shared helpers
  from test_support, which now fills the four new ColumnSpec fields.
  main's scale_by hash calls splitmix64::finalize, the same function as
  mix_connected_bits. 50 tests, as on main, none duplicated.
- aqpbm-planeval: the branch removed the old in-process evaluator, so
  main's edit to src/handle.rs (#183) is dropped with it and the
  branch's Cargo.toml is kept. The harness fills the new ColumnSpec
  fields.
- Cargo.lock: main's lockfile, with the branch's dependencies added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant