Skip to content

POC: [C++] Use xsimd for SpacedExpandRightward on 4/8 byte values - #55459

Draft
mapleFU wants to merge 2 commits into
apache:mainfrom
mapleFU:poc/spaced-expand-xsimd
Draft

mapleFU wants to merge 2 commits into
apache:mainfrom
mapleFU:poc/spaced-expand-xsimd

Conversation

@mapleFU

@mapleFU mapleFU commented Nov 9, 2026

Copy link
Copy Markdown
Member

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

This PR includes breaking changes to public APIs. (If there are any breaking changes to public APIs, please explain which changes are breaking. If not, you can remove this.)

This PR contains a "Critical Fix". (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.)

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Dispatch SpacedExpandRightward for 4 and 8 byte trivially copyable types
to a 128-bit SIMD implementation (NEON, SSE4.2), keeping the run based
implementation as the scalar fallback and for other widths.

The bitmap is walked one 64-bit word at a time: words with few nulls or
a single valid/null transition go through a run path (memmove/memset,
runs kept open across words), sparse words are scattered, and the rest
are expanded 8 values at a time with an xsimd byte swizzle driven by an
Arrow-owned lookup table. Every table index stays in [0, 16) and null
slots are cleared with a keep mask, so only defined swizzle semantics
are used and the bundled xsimd 14.2 is enough.

Behavior change: the SIMD path zeroes every null slot, the scalar path
only the trailing null_count slots.

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

mapleFU commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

This is just a POC by ai, I want to verify performance of SIMD SpaceShift. Don't review it for now

@mapleFU

mapleFU commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

@ursabot please benchmark lang=C++

@rok

rok commented Nov 10, 2026

Copy link
Copy Markdown
Member

Benchmark runs are scheduled for commit 1bc728e. Watch https://buildkite.com/apache-arrow and https://conbench.arrow-dev.org for updates. A comment will be posted here when the runs are complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants