mapleFU commented on code in PR #55449:
URL: https://github.com/apache/arrow/pull/55449#discussion_r4681299701
##########
cpp/src/arrow/util/alp/alp_compression.cc:
##########
@@ -524,16 +525,25 @@ template <typename TargetType>
void AlpCompression<T>::PatchExceptions(
std::span<const T> exceptions,
std::span<const AlpFormatConstants::PositionType> exception_positions,
- std::span<TargetType> outputs) {
+ const bool positions_strictly_increasing, std::span<TargetType> outputs) {
ARROW_DCHECK_EQ(exceptions.size(), exception_positions.size());
- // `ivdep` assumes the positions are distinct. The encoder writes them in
- // order, and loading a page rejects positions that do not increase.
- int64_t exception_idx = 0;
- ARROW_ALP_UNROLL_AND_ASSUME_INDEPENDENT
- for (const AlpFormatConstants::PositionType exception_position :
exception_positions) {
- ARROW_DCHECK_LT(exception_position, outputs.size());
- outputs[exception_position] = static_cast<T>(exceptions[exception_idx]);
- exception_idx++;
+ const size_t num_exceptions = exception_positions.size();
+ const auto patch_exception = [&](size_t i) {
+ const auto position = exception_positions[i];
+ ARROW_DCHECK_LT(position, outputs.size());
+ outputs[position] = static_cast<T>(exceptions[i]);
+ };
+ if (positions_strictly_increasing) {
+ // The encoder emits strictly increasing positions. Use the vectorized
+ // fast path for that common case.
Review Comment:
https://godbolt.org/z/xY51czqfq
Seem this would vectorize only with avx512f? x86 SSE4.2/AVX2 doesn't has
vscatter, and unroll might only affect little performance, unroll 4 with 50%
exception with only have 5% performance enhancement in my machine. And with
1-10% exception, the optimization <= 1.2% in my machine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]