Skip to content

fix: VarBinArray.DictMode reads dict offsets in a uniform loop, unblocking vectorization (#243)#245

Merged
dfa1 merged 1 commit into
mainfrom
fix/243-dictreadoff-hotloop
Jul 8, 2026
Merged

fix: VarBinArray.DictMode reads dict offsets in a uniform loop, unblocking vectorization (#243)#245
dfa1 merged 1 commit into
mainfrom
fix/243-dictreadoff-hotloop

Conversation

@dfa1

@dfa1 dfa1 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

VarBinArray.DictMode.forEachByteLength called dictReadOff(long) twice per row, and each call recomputed the invariant offset width, ran an invariant bounds check, and dispatched a variable-target switch(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:

  • I32 fast path (forEachI32OffsetByteLength): the common FSST/dict shape where value offsets are 32-bit. The dictCodesPType switch is hoisted once, and each specialized loop reads codes at a single fixed stride and computes lengths via i32OffsetLength at a constant 4-byte offset stride — leaving a uniform, vectorizable body with zero per-row switches.
  • Wide-offset general path: 64-bit and narrow offset ptypes keep the existing per-row dictReadCode/dictReadOff path (documented slow path).

Scalar accessors (getBytes/getByteLength/getString) intentionally keep the existing dictReadOff helper: its per-call VortexException bounds guard (ADR 0003) is pinned by getString_widthOvershootsBuffer_throwsVortexException, which constructs the array in // Given and expects the throw at access time — so the check cannot move to the constructor.

Tests

  • Existing VarBinArrayTest stays green.
  • Added forEachByteLength_i32Offsets_resolvesViaDict (fast path) and forEachByteLength_i64Offsets_resolvesViaDict (general path).
  • ./mvnw test -pl reader -q passes.

Closes #243

🤖 Generated with Claude Code

…cking vectorization (#243)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dfa1 dfa1 merged commit 8bcbedc into main Jul 8, 2026
6 checks passed
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.

VarBinArray.dictReadOff: per-row variable-target switch + bounds check regresses Utf8-dict scan (~12% on symbol), blocks vectorization

1 participant