andygrove commented on PR #12347: URL: https://github.com/apache/arrow-rs/pull/12347#issuecomment-7050978653
I ran the `set_bit_counter` benchmark at 661a54f on an AMD Ryzen 9 7950X3D (Zen 4, Linux 6.8, rustc 1.100.0). There are two builds: the default target, and `RUSTFLAGS="-C target-cpu=native"`. Times are criterion medians in µs. Speedup is `count_set_bits_offset` / `SetBitCounter`, so a value below 1x means the counter is slower. - **Forward:** the counter is 2.2x to 2.7x faster on the default build and 3x to 8.5x faster with native. The only forward case where it is slower is `width_256/constant/offset_0` on the default build (0.86x). That matches the baseline x86-64 case in the PR description. - **Reverse:** the counter is faster at widths 4 and 32. At width 256 it is slower on the default build (0.31x to 0.65x) and 1.05x to 1.77x faster with native. - **Shuffled:** the counter is 20x to 2000x slower. It takes about 1.5 ms at width 4 and about 100 ms at width 256, against roughly 70 to 130 µs for `count_set_bits_offset`. Each backward jump walks back word by word, so random order costs time proportional to the distance jumped. - With native, `count_set_bits_offset` itself got slower than on the default build (about 107 µs vs 71 µs at width 4). <details><summary>Results</summary> | Case | `count_set_bits_offset` | `SetBitCounter` | Speedup | `count_set_bits_offset`, native | `SetBitCounter`, native | Speedup, native | |---|--:|--:|--:|--:|--:|--:| | `width_4/constant/offset_0/forward` | 71.2 | 26.8 | 2.65x | 107.0 | 12.7 | 8.45x | | `width_4/constant/offset_0/reverse` | 71.3 | 27.2 | 2.62x | 108.0 | 13.9 | 7.79x | | `width_4/constant/offset_0/shuffled` | 71.9 | 1523.4 | 0.05x | 107.6 | 571.6 | 0.19x | | `width_4/constant/offset_3/forward` | 71.6 | 27.6 | 2.60x | 107.2 | 12.6 | 8.50x | | `width_4/constant/offset_3/reverse` | 71.1 | 27.7 | 2.57x | 107.3 | 14.0 | 7.64x | | `width_4/constant/offset_3/shuffled` | 71.9 | 1769.2 | 0.04x | 108.9 | 788.6 | 0.14x | | `width_4/random/offset_0/forward` | 66.0 | 26.7 | 2.47x | 104.7 | 13.0 | 8.06x | | `width_4/random/offset_0/reverse` | 66.4 | 27.8 | 2.39x | 104.6 | 14.5 | 7.22x | | `width_4/random/offset_0/shuffled` | 66.1 | 1520.4 | 0.04x | 104.4 | 649.7 | 0.16x | | `width_4/random/offset_3/forward` | 65.4 | 26.7 | 2.45x | 104.6 | 13.0 | 8.07x | | `width_4/random/offset_3/reverse` | 65.4 | 28.2 | 2.32x | 103.8 | 14.5 | 7.17x | | `width_4/random/offset_3/shuffled` | 65.3 | 1781.8 | 0.04x | 103.4 | 807.8 | 0.13x | | `width_32/constant/offset_0/forward` | 71.3 | 30.1 | 2.37x | 108.0 | 14.5 | 7.45x | | `width_32/constant/offset_0/reverse` | 70.7 | 42.7 | 1.66x | 107.7 | 24.4 | 4.41x | | `width_32/constant/offset_0/shuffled` | 71.2 | 11652.0 | 0.01x | 107.2 | 3831.6 | 0.03x | | `width_32/constant/offset_3/forward` | 71.7 | 31.4 | 2.28x | 106.6 | 14.5 | 7.33x | | `width_32/constant/offset_3/reverse` | 71.0 | 46.0 | 1.54x | 106.9 | 26.2 | 4.08x | | `width_32/constant/offset_3/shuffled` | 71.2 | 13630.0 | 0.01x | 108.4 | 5974.4 | 0.02x | | `width_32/random/offset_0/forward` | 67.5 | 29.8 | 2.26x | 103.2 | 26.2 | 3.94x | | `width_32/random/offset_0/reverse` | 68.1 | 42.7 | 1.59x | 103.1 | 35.9 | 2.87x | | `width_32/random/offset_0/shuffled` | 67.9 | 12050.0 | 0.01x | 104.3 | 3909.3 | 0.03x | | `width_32/random/offset_3/forward` | 67.7 | 30.5 | 2.22x | 103.6 | 15.3 | 6.77x | | `width_32/random/offset_3/reverse` | 67.5 | 46.3 | 1.46x | 103.9 | 28.2 | 3.69x | | `width_32/random/offset_3/shuffled` | 67.4 | 13806.0 | 0.00x | 103.3 | 6042.1 | 0.02x | | `width_256/constant/offset_0/forward` | 50.6 | 59.2 | 0.86x | 77.5 | 25.8 | 3.00x | | `width_256/constant/offset_0/reverse` | 50.5 | 160.3 | 0.31x | 77.3 | 73.4 | 1.05x | | `width_256/constant/offset_0/shuffled` | 50.5 | 94069.0 | 0.00x | 77.5 | 39399.0 | 0.00x | | `width_256/constant/offset_3/forward` | 86.3 | 67.4 | 1.28x | 115.4 | 30.6 | 3.78x | | `width_256/constant/offset_3/reverse` | 86.0 | 183.8 | 0.47x | 116.2 | 79.4 | 1.46x | | `width_256/constant/offset_3/shuffled` | 89.7 | 105980.0 | 0.00x | 115.5 | 46357.0 | 0.00x | | `width_256/random/offset_0/forward` | 106.3 | 60.3 | 1.76x | 132.4 | 28.1 | 4.71x | | `width_256/random/offset_0/reverse` | 105.1 | 161.1 | 0.65x | 132.7 | 74.8 | 1.77x | | `width_256/random/offset_0/shuffled` | 105.6 | 94559.0 | 0.00x | 132.1 | 32483.0 | 0.00x | | `width_256/random/offset_3/forward` | 106.2 | 67.9 | 1.56x | 132.1 | 31.4 | 4.21x | | `width_256/random/offset_3/reverse` | 106.2 | 188.4 | 0.56x | 133.7 | 91.2 | 1.47x | | `width_256/random/offset_3/shuffled` | 105.8 | 107190.0 | 0.00x | 133.4 | 44997.0 | 0.00x | </details> -- 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]
