fix: VarBinArray.DictMode reads dict offsets in a uniform loop, unblocking vectorization (#243)#245
Merged
Merged
Conversation
…cking vectorization (#243) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
VarBinArray.DictMode.forEachByteLengthcalleddictReadOff(long)twice per row, and each call recomputed the invariant offset width, ran an invariant bounds check, and dispatched a variable-targetswitch(dictValOffPType). Per the CLAUDE.md hot-loop rule, a variable-target switch per element blocks C2 auto-vectorization (regression introduced by #215's true-width offset read).The fix branch-splits the hot loop, hoisting both ptype dispatches out of the per-row body:
forEachI32OffsetByteLength): the common FSST/dict shape where value offsets are 32-bit. ThedictCodesPTypeswitch is hoisted once, and each specialized loop reads codes at a single fixed stride and computes lengths viai32OffsetLengthat a constant 4-byte offset stride — leaving a uniform, vectorizable body with zero per-row switches.dictReadCode/dictReadOffpath (documented slow path).Scalar accessors (
getBytes/getByteLength/getString) intentionally keep the existingdictReadOffhelper: its per-callVortexExceptionbounds guard (ADR 0003) is pinned bygetString_widthOvershootsBuffer_throwsVortexException, which constructs the array in// Givenand expects the throw at access time — so the check cannot move to the constructor.Tests
VarBinArrayTeststays green.forEachByteLength_i32Offsets_resolvesViaDict(fast path) andforEachByteLength_i64Offsets_resolvesViaDict(general path)../mvnw test -pl reader -qpasses.Closes #243
🤖 Generated with Claude Code