Codex/splayed clickbench#212
Merged
Merged
Conversation
The fused top-count path (use_emit_filter, n_keys>1) open-addresses
into one monolithic table sized to the row count. For a 10M-row
composite group-by — q32 `by {WatchID, ClientIP}` — that table is
~16M slots across three arrays (~290 MB); every probe is a cache
miss and the loop runs at memory latency.
group.c already has a radix-partitioned group path (radix_phase1/2/3)
that partitions rows into cache-sized chunks and groups each locally.
Gate the monolithic path to cap <= 2^19 slots; above that, bail via
the existing `goto skip_top_count_filter` to the radix path.
ClickBench 10M splayed: q32 1020->247ms, q18 1293->418ms,
q16 567->246ms. 2407/2408 tests pass.
Two algorithmic fixes to exec_group: 1. strlen-on-SYM aggregates (avg/sum(strlen(sym_col))) resolved the symbol per row via ray_sym_str — a spin-lock + dict lookup each call. ClickBench q27 `avg(strlen URL)` over 10M rows spent 91% of its time in ray_sym_str/sym_lock. Borrow the sym→string snapshot once before the da_accum dispatch and index it lock-free in both da_accum_row paths (all-SUM fast path and the general path). q27: 1111 ms -> ~100 ms. 2. The single-key sparse_i64 top-count path open-addresses into a monolithic table that rehashes up to ~16M entries for a high-cardinality key (q15 `by UserID`), cache-thrashing. Above 2^21 rows, bail to the radix-partitioned path. q15: 357 -> 230 ms. 2407/2408 tests pass.
…oup-by
The radix dispatch was gated `!rowsel`, so any composite group-by with
a WHERE clause fell back to the monolithic hash — scanning all 10M
rows into a row-count-sized table. q31 (`by {WatchID,ClientIP}` with
`where SearchPhrase<>''`) ran 650 ms despite the filter cutting the
input ~20x.
radix_phase1_fn already honours c->rowsel (skips non-passing rows
during the scatter), so the partitioned data only ever holds passing
rows — the gate was over-conservative. Dropping it routes filtered
composite group-bys onto the cache-friendly radix path.
q31: 650 -> 175 ms. 2407/2408 tests pass.
…osite group-by" This reverts commit 03004e9.
…ix path" This reverts commit 22edfd4.
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.
No description provided.