Skip to content

perf: branchless mask-select for listview zip#8264

Merged
robert3005 merged 5 commits into
developfrom
claude/wizardly-carson-6Cixf
Jul 2, 2026
Merged

perf: branchless mask-select for listview zip#8264
robert3005 merged 5 commits into
developfrom
claude/wizardly-carson-6Cixf

Conversation

@joseph-isaacs

@joseph-isaacs joseph-isaacs commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the per-element, data-dependent branch in the listview zip kernel's offset/size selection with a branchless, chunk-at-a-time mask select that the compiler can auto-vectorize.

For each 64-bit mask chunk, each bit is expanded to a full-width lane mask and both sides are blended with (t & m) | (f & !m) via a shared select_column helper, so the inner loop is branch-free regardless of mask shape. if_false offsets are shifted into the second half of the concatenated elements as before; sizes are taken verbatim from the chosen side.

The primitive-array zip kernel that was previously bundled here has been split into its own PR.

Changes

  • vortex-array/src/arrays/listview/compute/zip.rs: branchless chunked offset/size select via select_column; added a test that spans the 64-bit chunk boundary + remainder.
  • vortex-array/benches/listview_zip.rs: a small divan bench — one Fragmented (alternating) mask with non-nullable and nullable inputs.

Benchmark

Because the branchless select is mask-shape-independent, the bench uses a single Fragmented mask (the worst case for the replaced per-element branch) with both nullability variants. LEN is 8,192: listview zip cost is dominated by element concatenation and per-list canonicalization, so a few thousand lists already exercise the select while keeping each case well under a few hundred microseconds (~37 µs non-null, ~41 µs nullable locally).

The kernel change itself is a single-to-low-double-digit-percent win on the offset/size select; end-to-end listview zip is dominated by element concatenation + canonicalization, so the select is a small slice of total cost.

Testing

  • vortex-array listview zip tests pass (incl. the new multi-chunk-span test); cargo +nightly fmt and clippy -D warnings (default + all-features) clean.

https://claude.ai/code/session_01N5ivPiCJy7dGQjMEP7ips9

@joseph-isaacs joseph-isaacs added the changelog/performance A performance improvement label Jun 5, 2026 — with Claude
@codspeed-hq

codspeed-hq Bot commented Jun 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 1595 untouched benchmarks
🆕 2 new benchmarks
⏩ 4 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 Simulation nonnull N/A 302.5 µs N/A
🆕 Simulation nullable N/A 315.4 µs N/A

Comparing claude/wizardly-carson-6Cixf (3b5db68) with develop (0026d3a)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@joseph-isaacs joseph-isaacs marked this pull request as draft June 5, 2026 10:43
@joseph-isaacs joseph-isaacs force-pushed the claude/wizardly-carson-6Cixf branch from d11d3b8 to ddeb10d Compare June 5, 2026 14:33
@joseph-isaacs joseph-isaacs changed the title Add branchless zip kernel for primitive arrays perf: branchless mask-select for primitive and listview zip Jun 5, 2026
@joseph-isaacs joseph-isaacs marked this pull request as ready for review June 5, 2026 14:34
@joseph-isaacs joseph-isaacs force-pushed the claude/wizardly-carson-6Cixf branch 2 times, most recently from 8ea7fb9 to f05b6a0 Compare June 5, 2026 15:32
@joseph-isaacs joseph-isaacs changed the title perf: branchless mask-select for primitive and listview zip perf: branchless mask-select for listview zip Jun 5, 2026
@joseph-isaacs joseph-isaacs requested a review from a team June 5, 2026 18:17
Comment thread vortex-array/src/arrays/listview/compute/zip.rs Outdated
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been marked as stale because it has been open for 14 days with no activity. Please comment or remove the stale label if you wish to keep it active, otherwise it will be closed in 7 days

@github-actions github-actions Bot added the stale This PR is stale and will be auto-closed soon label Jun 23, 2026
@joseph-isaacs joseph-isaacs force-pushed the claude/wizardly-carson-6Cixf branch from a9516cf to 8c26832 Compare June 23, 2026 02:31
@github-actions github-actions Bot removed the stale This PR is stale and will be auto-closed soon label Jun 25, 2026
@robert3005 robert3005 enabled auto-merge (squash) June 29, 2026 13:24
claude and others added 5 commits July 2, 2026 18:26
Replace the per-element, data-dependent branch in the listview zip kernel's
offset/size selection with a branchless, chunk-at-a-time mask select that the
compiler can auto-vectorize. For each 64-bit mask chunk, each bit is expanded
to a full-width lane mask and both sides are blended with `(t & m) | (f & !m)`
via a shared `select_column` helper, so the inner loop is branch-free
regardless of mask shape. `if_false` offsets are shifted into the second half
of the concatenated elements as before.

Adds a `listview_zip` divan benchmark across fragmented/block/sparse/dense
masks for nullable and non-nullable inputs.

Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Reduce the divan bench to one Fragmented (alternating) mask with non-nullable
and nullable inputs, and lower LEN to 8192 so each case stays well under a few
hundred microseconds. The branchless chunked select is mask-shape-independent,
so a single shape suffices; drop the now-unused MaskShape matrix.

Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
CodSpeed's instruction-count simulation runs ~10x local walltime, putting the
8192-list bench at ~550us there. Drop to 4096 lists so each case stays well
under a few hundred microseconds in CI while still exercising the select.

Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 force-pushed the claude/wizardly-carson-6Cixf branch from 1e8c616 to 3b5db68 Compare July 2, 2026 17:27
@robert3005 robert3005 merged commit 5172987 into develop Jul 2, 2026
70 of 71 checks passed
@robert3005 robert3005 deleted the claude/wizardly-carson-6Cixf branch July 2, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants