Repository navigation
Conversation
…ector Pre-resolve the power-of-ten scaling multipliers once before the vector loops in Decompress(), EncodeVector(), and EstimateCompressedSizeBits() instead of passing AlpExponentAndFactor by value into EncodeValue()/DecodeValue() on every element. On AArch64 (both macOS Apple Clang and upstream Linux Clang 19-21), passing the 2-byte AlpExponentAndFactor struct by value into DecodeValue() inside the loop leaves a loop-carried undef-padded i64 PHI after AAPCS64 ABI lowering, preventing LICM from hoisting the power-of-ten table load and blocking auto-vectorization on all three Decompress instantiations (float->float, float->double, double->double).
mapleFU
marked this pull request as ready for review
November 21, 2026 14:08
mapleFU
force-pushed
the
alp-auto-vec
branch
from
November 21, 2026 14:08
094d2ec to
daabd95
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the ALP multiplier-hoisting change.
No open issues 🎉
What changed in this PR
This PR optimizes C++ ALP compression and decompression by resolving decimal multipliers outside per-value loops, targeting Clang auto-vectorization on AArch64 without changing numerical behavior.
Changes:
- Adds helpers to resolve type-specific encode and decode multipliers.
- Reuses resolved multipliers in size estimation, encoding, and decompression while preserving multiplication order and source-type precision.
| File | Description |
|---|---|
cpp/src/arrow/util/alp/alp_compression.cc |
Moves power-of-ten table lookups outside ALP processing loops to enable vectorization. |
Review effort: Balanced
Member
Author
wgtmac
reviewed
Nov 23, 2026
| Constants::GetFactor(exponent_and_factor.factor); | ||
| // The two decimal multipliers applied by EncodeValue() or DecodeValue(), | ||
| // resolved once per vector from the power-of-ten tables. | ||
| struct Multipliers { |
Member
|
Interestingly, it doesn't seem to make a difference on my x86 machine (gcc 15.3.0, AMD Zen 2). |
Member
Author
|
This only works on AArch. gcc has another problem about |
Member
Author
|
Maybe we can waiting for #55449 , and I can close this firstly |
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.
Rationale for this change
Part of #55448.
In
AlpCompression<T>::Decompress(),AlpInlines<T>::DecodeValue()previously tookAlpExponentAndFactor(a 2-byte struct) by value and looked up the power-of-ten tables inside the loop.On AArch64 (both macOS Apple Clang and upstream Linux Clang 19–21), AAPCS64 lowers the 2-byte by-value struct parameter into an
i64withundefupper 48 bits. After inlining, LLVM leaves a loop-carriedphi i64and fails to hoist the negated-exponent table load (kTable[-exponent + 10]), causingLoopVectorizeto bail out withcannot identify array boundson all threeDecompressinstantiations (float -> float,float -> double,double -> double).Godbolt repro (upstream Clang 20.1,
aarch64vsx86-64): https://godbolt.org/z/1ov94ccYMWhat changes are included in this PR?
AlpInlines<T>::MultiplierswithGetEncodeMultipliers()/GetDecodeMultipliers()and pass the pre-resolved multipliers intoEncodeValue()/DecodeValue().Decompress(),EncodeVector(), andEstimateCompressedSizeBits().Benchmark on Apple M5 Max (
N = 65536, Release):DecodeFloat(constant64.0)DecodeDouble(constant64.0)DecodeFloat(2-decimal prices,bit_width > 0)DecodeDouble(2-decimal prices,bit_width > 0)DecodeFloat(2-decimal + 1% exceptions)DecodeDouble(2-decimal + 1% exceptions)Are these changes tested?
Covered by existing ALP and Parquet encoding tests (
arrow-encoding-utility-test --gtest_filter='*Alp*'andparquet-encoding-test --gtest_filter='*Alp*:*ALP*').Are there any user-facing changes?
No.
Was AI used for this PR?
PR code and description written by:
Reviewed before submission by: