mbutrovich commented on issue #12467: URL: https://github.com/apache/arrow-rs/issues/12467#issuecomment-7172613108
Thanks @viirya. > I'd keep `memcmp` (`a[k..].cmp(&b[k..])`) for long shared prefixes instead of scanning with `common_prefix_len` and comparing the byte at the mismatch. The amd64 `arrow_writer` runs on #12470 include `large_string_non_null` and `small_string_shared_prefix`, so they will show whether the block scan keeps up with glibc's `memcmp`. If it doesn't, where should the bound go? Inside the inlined `cmp_bytes`, `memcmp` adds a second call target to every caller's loop. Inside the out-of-line scan, the function stops being a leaf, which #12460 found lost its gain. > Relatedly, #10549 and #12460 don't really conflict. Fair, one needs the position and the other only the order. > The popcount kernel (`count_ones_words`) would have to move into the new crate, with `arrow-buffer` delegating to it. #12470 does this: [8041ad3](https://github.com/apache/arrow-rs/pull/12470/commits/8041ad3e0db77146b2e3e3ac5ffc9fa54cddb259) moves `bit_chunk_iterator`, kernel included, into `arrow-bitutils`, and `arrow-buffer` re-exports it. > `UnalignedBitChunk::new`'s setup (`align_to`, prefix/suffix masks) needs a benchmark on short ranges before switching. Agreed, and no existing benchmark reaches that path. The arrow reader skips flat optional columns through `PackedDecoder` ([mod.rs#L118](https://github.com/apache/arrow-rs/blob/8befa3cd899afea17b1969f0f4fd4491e3f81439/parquet/src/arrow/record_reader/mod.rs#L118), [definition_levels.rs#L467-L483](https://github.com/apache/arrow-rs/blob/8befa3cd899afea17b1969f0f4fd4491e3f81439/parquet/src/arrow/record_reader/definition_levels.rs#L467-L483)), which already counts with `UnalignedBitChunk`. `BitReader::skip_and_count_ones` only runs when `max_def_level` is 1 and the levels go through `DefinitionLevelDecoderImpl` ([decoder.rs#L493](https://github.com/apache/arrow-rs/blob/8befa3cd899afea17b1969f0f4fd4491e3f81439/parquet/src/column/reader/decoder.rs#L493), [bit_util.rs#L1069](https://github.com/apache/arrow-rs/blob/8befa3cd899afea17b1969f0f4fd4491e3f81439/parquet/src/util/bit_util.rs#L1069)). A micro-benchmark of the two on 8 to 504 bit ranges would cover it. > Each caller needs re-measuring, with LTO as well as without, since downstream users like DataFusion often enable it. The bot builds with thin LTO. `cmp_bytes` fixes its split with `#[inline(always)]` and `#[inline(never)]`, so the split doesn't depend on the LTO setting. `BitChunks::new` is the open one: `arrow-buffer`'s own calls to it now cross a crate boundary, and the `boolean_append_packed` runs will show what that costs. > I'd only add a primitive once it has two real callers. Agreed. `prefix_key` is private in #12470. `prefix_key_u128` has one caller, so I'll drop it too. > I wouldn't hold it for this. Agreed. > That's worth its own fix now. Agreed that it needs its own issue. I'm not planning to take it on. > if byte comparison and VLQ land there too, `arrow-bitutils` may be too narrow a name. Agreed. I'm open to suggestions. -- 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]
