Skip to content

fix: safely decode ARM64 StreamVByte tails - #2

Merged
ajroetker merged 2 commits into
antflydb:antflydb-mainfrom
ajroetker:fix/arm64-streamvbyte-tails
Jul 24, 2026
Merged

fix: safely decode ARM64 StreamVByte tails#2
ajroetker merged 2 commits into
antflydb:antflydb-mainfrom
ajroetker:fix/arm64-streamvbyte-tails

Conversation

@ajroetker

Copy link
Copy Markdown

Summary

  • send only full-window StreamVByte groups through the SIMD kernel
  • scalar-decode groups that lack the 16-byte input window required by the NEON implementation
  • redo the decode scalar if SIMD consumption differs from the planned safe prefix
  • add tail-completion and truncation regressions across encoded widths and group sizes

Root cause

The ARM64 batch decoder requires a full 16-byte load window for each four-value group. For short final groups, it could zero-fill output while still reporting complete decoded and consumed counts. Zapx therefore had no signal that location columns were corrupted.

This helper computes the safe SIMD prefix from the control bytes and completes the tail with the scalar decoder. It retains SIMD for the valid prefix and removes the need for HWY_NO_SIMD=1 as a correctness mitigation.

Validation

  • env GOWORK=off go test ./... on ARM64
  • env GOWORK=off HWY_NO_SIMD=1 go test -count=1 ./...
  • new regressions cover short tails, all encoded widths, and truncation beyond zero padding

Related incident: antflydb/antfly#381

excenter added 2 commits July 24, 2026 12:39
… groups

The NEON batch decoder requires a full 16-byte load window per group.
Groups without one take unreliable tail paths: on linux/arm64 the kernel
zero-fills their output while still reporting full decoded/dataConsumed
success, so the corruption is undetectable from the return values.
Route all decodes through decodeStreamVByteFull, which hands the kernel
only the provably safe group prefix, scalar-decodes the remainder, and
redoes everything scalar if the kernel deviates from the plan.

This removes the need for HWY_NO_SIMD=1 as a correctness mitigation.
Red on the parent commit's raw kernel calls (silent zeroed tails, the
TestOpen/TestStreamVByte* arm64 failures); green with the safe-prefix
helper under both NEON and HWY_NO_SIMD=1. Includes a truncation case
that cuts into real value bytes past the final group's zero padding.
@ajroetker
ajroetker merged commit 4f612d5 into antflydb:antflydb-main Jul 24, 2026
9 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.

2 participants