Skip to content

Conversation

@rluvaton
Copy link
Member

Which issue does this PR close?

N/A

Rationale for this change

Making the row length calculation faster which result in faster row conversion

What changes are included in this PR?

  1. Instead of iterating over the bytes and getting the length from the byte slice, we use the offsets directly, this is faster as it saves us going to the buffer
  2. Added new API for GenericByteViewArray (explained below)

Are these changes tested?

Yes

Are there any user-facing changes?

Yes, added lengths function to GenericByteViewArray to get an iterator over the lengths of the items in the array


Related to:

@github-actions github-actions bot added the arrow Changes to the arrow crate label Dec 31, 2025
@rluvaton
Copy link
Member Author

run benchmark row_format

@alamb-ghbot
Copy link

🤖 ./gh_compare_arrow.sh gh_compare_arrow.sh Running
Linux aal-dev 6.14.0-1018-gcp #19~24.04.1-Ubuntu SMP Wed Sep 24 23:23:09 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Comparing improve-perf-of-row-encoding-for-calculating-view-lengths (0e44d8c) to 843bee2 diff
BENCH_NAME=row_format
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental --bench row_format
BENCH_FILTER=
BENCH_BRANCH_NAME=improve-perf-of-row-encoding-for-calculating-view-lengths
Results will be posted here when complete

@alamb-ghbot
Copy link

🤖: Benchmark completed

Details

group                                                                                                                         improve-perf-of-row-encoding-for-calculating-view-lengths    main
-----                                                                                                                         ---------------------------------------------------------    ----
append_rows 10 large_list(0) of u64(0)                                                                                        1.00    628.5±7.72ns        ? ?/sec                          1.02    640.5±7.49ns        ? ?/sec
append_rows 10 list(0) of u64(0)                                                                                              1.00    685.0±7.56ns        ? ?/sec                          1.02   700.2±10.73ns        ? ?/sec
append_rows 4096 4096 string_dictionary(20, 0.5), string_dictionary(30, 0), string_dictionary(100, 0), i64(0)                 1.00    366.6±3.64µs        ? ?/sec                          1.01    371.2±3.05µs        ? ?/sec
append_rows 4096 bool(0, 0.5)                                                                                                 1.41     12.1±0.27µs        ? ?/sec                          1.00      8.6±0.07µs        ? ?/sec
append_rows 4096 bool(0.3, 0.5)                                                                                               1.00     14.6±0.09µs        ? ?/sec                          1.16     17.0±0.36µs        ? ?/sec
append_rows 4096 i64(0)                                                                                                       1.00      7.7±0.21µs        ? ?/sec                          1.01      7.7±0.14µs        ? ?/sec
append_rows 4096 i64(0.3)                                                                                                     1.00     14.0±0.17µs        ? ?/sec                          1.10     15.4±0.43µs        ? ?/sec
append_rows 4096 large_list(0) of u64(0)                                                                                      1.00    155.0±1.97µs        ? ?/sec                          1.05    162.8±1.84µs        ? ?/sec
append_rows 4096 large_list(0) sliced to 10 of u64(0)                                                                         1.00   895.1±14.58ns        ? ?/sec                          1.01    905.3±4.54ns        ? ?/sec
append_rows 4096 list(0) of u64(0)                                                                                            1.00    148.6±2.33µs        ? ?/sec                          1.12    166.4±2.42µs        ? ?/sec
append_rows 4096 list(0) sliced to 10 of u64(0)                                                                               1.00   993.8±19.41ns        ? ?/sec                          1.03  1027.6±25.42ns        ? ?/sec
append_rows 4096 string view(1..100, 0)                                                                                       1.00    110.9±0.49µs        ? ?/sec                          1.05    115.9±2.75µs        ? ?/sec
append_rows 4096 string view(1..100, 0.5)                                                                                     1.00    102.3±0.54µs        ? ?/sec                          1.01    103.1±1.60µs        ? ?/sec
append_rows 4096 string view(10, 0)                                                                                           1.00     48.9±0.53µs        ? ?/sec                          1.06     52.0±0.55µs        ? ?/sec
append_rows 4096 string view(100, 0)                                                                                          1.03     78.0±4.59µs        ? ?/sec                          1.00     75.7±0.64µs        ? ?/sec
append_rows 4096 string view(100, 0.5)                                                                                        1.04     88.7±1.29µs        ? ?/sec                          1.00     85.3±1.12µs        ? ?/sec
append_rows 4096 string view(30, 0)                                                                                           1.00     52.3±0.82µs        ? ?/sec                          1.03     54.1±1.08µs        ? ?/sec
append_rows 4096 string(10, 0)                                                                                                1.00     45.1±0.26µs        ? ?/sec                          1.09     49.3±0.24µs        ? ?/sec
append_rows 4096 string(100, 0)                                                                                               1.03     73.9±1.47µs        ? ?/sec                          1.00     71.9±1.21µs        ? ?/sec
append_rows 4096 string(100, 0.5)                                                                                             1.09     90.0±1.76µs        ? ?/sec                          1.00     82.3±1.12µs        ? ?/sec
append_rows 4096 string(20, 0.5), string(30, 0), string(100, 0), i64(0)                                                       1.02    223.0±4.23µs        ? ?/sec                          1.00    218.8±1.54µs        ? ?/sec
append_rows 4096 string(30, 0)                                                                                                1.00     47.7±1.63µs        ? ?/sec                          1.04     49.4±0.29µs        ? ?/sec
append_rows 4096 string_dictionary(10, 0)                                                                                     1.00     72.0±0.51µs        ? ?/sec                          1.05     75.4±0.50µs        ? ?/sec
append_rows 4096 string_dictionary(100, 0)                                                                                    1.00    146.4±6.87µs        ? ?/sec                          1.00    145.7±1.97µs        ? ?/sec
append_rows 4096 string_dictionary(100, 0.5)                                                                                  1.01    109.0±0.78µs        ? ?/sec                          1.00    108.2±1.12µs        ? ?/sec
append_rows 4096 string_dictionary(30, 0)                                                                                     1.00     76.0±0.87µs        ? ?/sec                          1.02     77.4±2.47µs        ? ?/sec
append_rows 4096 string_dictionary_low_cardinality(10, 0)                                                                     1.00     27.1±0.18µs        ? ?/sec                          1.00     27.1±0.10µs        ? ?/sec
append_rows 4096 string_dictionary_low_cardinality(100, 0)                                                                    1.00     45.6±0.69µs        ? ?/sec                          1.02     46.6±0.47µs        ? ?/sec
append_rows 4096 string_dictionary_low_cardinality(30, 0)                                                                     1.00     27.0±0.23µs        ? ?/sec                          1.01     27.1±0.27µs        ? ?/sec
append_rows 4096 u64(0)                                                                                                       1.00      7.6±0.19µs        ? ?/sec                          1.00      7.6±0.17µs        ? ?/sec
append_rows 4096 u64(0.3)                                                                                                     1.00     14.4±1.30µs        ? ?/sec                          1.02     14.7±0.20µs        ? ?/sec
convert_columns 10 large_list(0) of u64(0)                                                                                    1.00   905.7±14.18ns        ? ?/sec                          1.02   921.4±72.49ns        ? ?/sec
convert_columns 10 list(0) of u64(0)                                                                                          1.00    951.8±5.11ns        ? ?/sec                          1.01    958.5±8.91ns        ? ?/sec
convert_columns 4096 4096 string_dictionary(20, 0.5), string_dictionary(30, 0), string_dictionary(100, 0), i64(0)             1.00    370.8±5.30µs        ? ?/sec                          1.01    375.3±4.77µs        ? ?/sec
convert_columns 4096 bool(0, 0.5)                                                                                             1.39     12.4±0.08µs        ? ?/sec                          1.00      8.9±0.05µs        ? ?/sec
convert_columns 4096 bool(0.3, 0.5)                                                                                           1.00     15.0±0.39µs        ? ?/sec                          1.14     17.2±0.24µs        ? ?/sec
convert_columns 4096 i64(0)                                                                                                   1.00      8.2±0.33µs        ? ?/sec                          1.01      8.3±0.13µs        ? ?/sec
convert_columns 4096 i64(0.3)                                                                                                 1.00     14.4±0.28µs        ? ?/sec                          1.08     15.6±0.30µs        ? ?/sec
convert_columns 4096 large_list(0) of u64(0)                                                                                  1.00    155.4±3.47µs        ? ?/sec                          1.05    162.9±1.43µs        ? ?/sec
convert_columns 4096 large_list(0) sliced to 10 of u64(0)                                                                     1.00  1166.5±18.64ns        ? ?/sec                          1.08   1258.9±8.87ns        ? ?/sec
convert_columns 4096 list(0) of u64(0)                                                                                        1.00    149.0±1.33µs        ? ?/sec                          1.12    166.4±1.54µs        ? ?/sec
convert_columns 4096 list(0) sliced to 10 of u64(0)                                                                           1.00  1276.2±11.68ns        ? ?/sec                          1.04  1331.5±10.97ns        ? ?/sec
convert_columns 4096 string view(1..100, 0)                                                                                   1.00    111.5±0.94µs        ? ?/sec                          1.03    114.8±0.34µs        ? ?/sec
convert_columns 4096 string view(1..100, 0.5)                                                                                 1.00    102.8±1.16µs        ? ?/sec                          1.01    103.3±2.07µs        ? ?/sec
convert_columns 4096 string view(10, 0)                                                                                       1.00     49.4±0.97µs        ? ?/sec                          1.07     52.6±0.20µs        ? ?/sec
convert_columns 4096 string view(100, 0)                                                                                      1.03     77.9±0.69µs        ? ?/sec                          1.00     75.3±1.01µs        ? ?/sec
convert_columns 4096 string view(100, 0.5)                                                                                    1.04     89.3±0.99µs        ? ?/sec                          1.00     85.8±0.47µs        ? ?/sec
convert_columns 4096 string view(30, 0)                                                                                       1.00     52.5±1.06µs        ? ?/sec                          1.03     54.0±0.92µs        ? ?/sec
convert_columns 4096 string(10, 0)                                                                                            1.00     45.6±0.46µs        ? ?/sec                          1.07     48.9±0.16µs        ? ?/sec
convert_columns 4096 string(100, 0)                                                                                           1.03     74.5±0.62µs        ? ?/sec                          1.00     72.4±1.23µs        ? ?/sec
convert_columns 4096 string(100, 0.5)                                                                                         1.11     90.9±0.43µs        ? ?/sec                          1.00     82.1±0.34µs        ? ?/sec
convert_columns 4096 string(20, 0.5), string(30, 0), string(100, 0), i64(0)                                                   1.01    223.1±4.27µs        ? ?/sec                          1.00    221.6±3.44µs        ? ?/sec
convert_columns 4096 string(30, 0)                                                                                            1.00     47.6±0.37µs        ? ?/sec                          1.04     49.7±0.49µs        ? ?/sec
convert_columns 4096 string_dictionary(10, 0)                                                                                 1.00     73.6±1.69µs        ? ?/sec                          1.03     76.0±0.79µs        ? ?/sec
convert_columns 4096 string_dictionary(100, 0)                                                                                1.00    147.2±2.25µs        ? ?/sec                          1.00    146.7±2.60µs        ? ?/sec
convert_columns 4096 string_dictionary(100, 0.5)                                                                              1.01    111.1±3.03µs        ? ?/sec                          1.00    110.3±2.00µs        ? ?/sec
convert_columns 4096 string_dictionary(30, 0)                                                                                 1.00     76.4±1.07µs        ? ?/sec                          1.03     78.6±1.15µs        ? ?/sec
convert_columns 4096 string_dictionary_low_cardinality(10, 0)                                                                 1.01     28.3±0.99µs        ? ?/sec                          1.00     27.9±0.40µs        ? ?/sec
convert_columns 4096 string_dictionary_low_cardinality(100, 0)                                                                1.00     47.2±1.30µs        ? ?/sec                          1.01     47.5±1.14µs        ? ?/sec
convert_columns 4096 string_dictionary_low_cardinality(30, 0)                                                                 1.00     28.6±1.10µs        ? ?/sec                          1.00     28.5±0.52µs        ? ?/sec
convert_columns 4096 u64(0)                                                                                                   1.00      7.9±0.20µs        ? ?/sec                          1.03      8.1±0.13µs        ? ?/sec
convert_columns 4096 u64(0.3)                                                                                                 1.00     14.5±0.27µs        ? ?/sec                          1.02     14.9±0.12µs        ? ?/sec
convert_columns_prepared 10 large_list(0) of u64(0)                                                                           1.00    678.3±7.53ns        ? ?/sec                          1.03   698.8±13.09ns        ? ?/sec
convert_columns_prepared 10 list(0) of u64(0)                                                                                 1.00    730.9±7.26ns        ? ?/sec                          1.04    759.5±7.48ns        ? ?/sec
convert_columns_prepared 4096 4096 string_dictionary(20, 0.5), string_dictionary(30, 0), string_dictionary(100, 0), i64(0)    1.00    366.3±7.54µs        ? ?/sec                          1.01    370.7±4.39µs        ? ?/sec
convert_columns_prepared 4096 bool(0, 0.5)                                                                                    1.40     12.3±0.32µs        ? ?/sec                          1.00      8.8±0.04µs        ? ?/sec
convert_columns_prepared 4096 bool(0.3, 0.5)                                                                                  1.00     14.9±0.48µs        ? ?/sec                          1.16     17.2±0.36µs        ? ?/sec
convert_columns_prepared 4096 i64(0)                                                                                          1.00      7.8±0.15µs        ? ?/sec                          1.00      7.8±0.15µs        ? ?/sec
convert_columns_prepared 4096 i64(0.3)                                                                                        1.00     14.1±0.08µs        ? ?/sec                          1.08     15.3±0.11µs        ? ?/sec
convert_columns_prepared 4096 large_list(0) of u64(0)                                                                         1.00    155.2±1.55µs        ? ?/sec                          1.05    162.7±1.61µs        ? ?/sec
convert_columns_prepared 4096 large_list(0) sliced to 10 of u64(0)                                                            1.00   939.0±15.71ns        ? ?/sec                          1.10   1032.1±4.80ns        ? ?/sec
convert_columns_prepared 4096 list(0) of u64(0)                                                                               1.00    150.1±9.29µs        ? ?/sec                          1.10    165.8±1.07µs        ? ?/sec
convert_columns_prepared 4096 list(0) sliced to 10 of u64(0)                                                                  1.00   1016.7±9.35ns        ? ?/sec                          1.09  1113.1±12.93ns        ? ?/sec
convert_columns_prepared 4096 string view(1..100, 0)                                                                          1.00    111.6±2.15µs        ? ?/sec                          1.03    114.8±0.34µs        ? ?/sec
convert_columns_prepared 4096 string view(1..100, 0.5)                                                                        1.00    102.4±0.73µs        ? ?/sec                          1.01    103.5±4.08µs        ? ?/sec
convert_columns_prepared 4096 string view(10, 0)                                                                              1.00     49.0±0.19µs        ? ?/sec                          1.07     52.3±0.49µs        ? ?/sec
convert_columns_prepared 4096 string view(100, 0)                                                                             1.01     77.1±0.44µs        ? ?/sec                          1.00     76.0±1.46µs        ? ?/sec
convert_columns_prepared 4096 string view(100, 0.5)                                                                           1.04     88.8±0.65µs        ? ?/sec                          1.00     85.7±0.89µs        ? ?/sec
convert_columns_prepared 4096 string view(30, 0)                                                                              1.00     52.4±0.86µs        ? ?/sec                          1.03     54.0±1.61µs        ? ?/sec
convert_columns_prepared 4096 string(10, 0)                                                                                   1.00     45.2±0.15µs        ? ?/sec                          1.09     49.1±2.65µs        ? ?/sec
convert_columns_prepared 4096 string(100, 0)                                                                                  1.03     74.0±1.29µs        ? ?/sec                          1.00     71.9±0.85µs        ? ?/sec
convert_columns_prepared 4096 string(100, 0.5)                                                                                1.09     90.1±0.89µs        ? ?/sec                          1.00     82.3±0.68µs        ? ?/sec
convert_columns_prepared 4096 string(20, 0.5), string(30, 0), string(100, 0), i64(0)                                          1.02   224.9±13.20µs        ? ?/sec                          1.00    220.1±3.04µs        ? ?/sec
convert_columns_prepared 4096 string(30, 0)                                                                                   1.00     47.4±0.11µs        ? ?/sec                          1.04     49.5±0.27µs        ? ?/sec
convert_columns_prepared 4096 string_dictionary(10, 0)                                                                        1.00     72.8±1.13µs        ? ?/sec                          1.04     75.5±0.58µs        ? ?/sec
convert_columns_prepared 4096 string_dictionary(100, 0)                                                                       1.00    144.9±2.54µs        ? ?/sec                          1.01    146.5±1.58µs        ? ?/sec
convert_columns_prepared 4096 string_dictionary(100, 0.5)                                                                     1.02    109.3±0.56µs        ? ?/sec                          1.00    107.4±0.41µs        ? ?/sec
convert_columns_prepared 4096 string_dictionary(30, 0)                                                                        1.00     76.1±1.89µs        ? ?/sec                          1.01     77.1±1.69µs        ? ?/sec
convert_columns_prepared 4096 string_dictionary_low_cardinality(10, 0)                                                        1.00     27.5±0.97µs        ? ?/sec                          1.00     27.3±0.52µs        ? ?/sec
convert_columns_prepared 4096 string_dictionary_low_cardinality(100, 0)                                                       1.00     45.8±0.16µs        ? ?/sec                          1.02     46.8±1.78µs        ? ?/sec
convert_columns_prepared 4096 string_dictionary_low_cardinality(30, 0)                                                        1.00     27.3±0.38µs        ? ?/sec                          1.00     27.3±0.39µs        ? ?/sec
convert_columns_prepared 4096 u64(0)                                                                                          1.00      7.7±0.23µs        ? ?/sec                          1.00      7.7±0.11µs        ? ?/sec
convert_columns_prepared 4096 u64(0.3)                                                                                        1.00     14.4±0.27µs        ? ?/sec                          1.03     14.8±0.24µs        ? ?/sec
convert_rows 10 large_list(0) of u64(0)                                                                                       1.08  1688.5±21.88ns        ? ?/sec                          1.00  1562.0±23.10ns        ? ?/sec
convert_rows 10 list(0) of u64(0)                                                                                             1.07  1760.9±24.11ns        ? ?/sec                          1.00  1649.0±39.08ns        ? ?/sec
convert_rows 4096 4096 string_dictionary(20, 0.5), string_dictionary(30, 0), string_dictionary(100, 0), i64(0)                1.06   318.5±23.15µs        ? ?/sec                          1.00    300.0±2.82µs        ? ?/sec
convert_rows 4096 bool(0, 0.5)                                                                                                1.06     17.5±1.76µs        ? ?/sec                          1.00     16.4±0.04µs        ? ?/sec
convert_rows 4096 bool(0.3, 0.5)                                                                                              1.04     17.2±0.16µs        ? ?/sec                          1.00     16.6±1.19µs        ? ?/sec
convert_rows 4096 i64(0)                                                                                                      1.00     33.2±0.10µs        ? ?/sec                          1.05     34.9±0.76µs        ? ?/sec
convert_rows 4096 i64(0.3)                                                                                                    1.00     33.2±0.14µs        ? ?/sec                          1.05     34.7±0.23µs        ? ?/sec
convert_rows 4096 large_list(0) of u64(0)                                                                                     1.00    270.4±1.88µs        ? ?/sec                          1.00    271.0±5.52µs        ? ?/sec
convert_rows 4096 large_list(0) sliced to 10 of u64(0)                                                                        1.00      2.1±0.02µs        ? ?/sec                          1.00      2.1±0.03µs        ? ?/sec
convert_rows 4096 list(0) of u64(0)                                                                                           1.01    272.1±4.25µs        ? ?/sec                          1.00    268.8±9.16µs        ? ?/sec
convert_rows 4096 list(0) sliced to 10 of u64(0)                                                                              1.01      2.2±0.07µs        ? ?/sec                          1.00      2.2±0.03µs        ? ?/sec
convert_rows 4096 string view(1..100, 0)                                                                                      1.00    168.5±1.58µs        ? ?/sec                          1.04    175.6±1.57µs        ? ?/sec
convert_rows 4096 string view(1..100, 0.5)                                                                                    1.00    133.5±2.87µs        ? ?/sec                          1.06    141.0±2.49µs        ? ?/sec
convert_rows 4096 string view(10, 0)                                                                                          1.00     75.6±0.97µs        ? ?/sec                          1.10     83.4±1.69µs        ? ?/sec
convert_rows 4096 string view(100, 0)                                                                                         1.00    122.4±1.50µs        ? ?/sec                          1.05    128.7±0.95µs        ? ?/sec
convert_rows 4096 string view(100, 0.5)                                                                                       1.00    112.0±2.38µs        ? ?/sec                          1.05    118.0±0.68µs        ? ?/sec
convert_rows 4096 string view(30, 0)                                                                                          1.00     86.7±4.41µs        ? ?/sec                          1.08     93.9±0.46µs        ? ?/sec
convert_rows 4096 string(10, 0)                                                                                               1.10     66.6±4.36µs        ? ?/sec                          1.00     60.4±0.52µs        ? ?/sec
convert_rows 4096 string(100, 0)                                                                                              1.03    114.8±2.29µs        ? ?/sec                          1.00    110.9±2.21µs        ? ?/sec
convert_rows 4096 string(100, 0.5)                                                                                            1.06    109.3±0.47µs        ? ?/sec                          1.00    103.5±0.51µs        ? ?/sec
convert_rows 4096 string(20, 0.5), string(30, 0), string(100, 0), i64(0)                                                      1.05   317.1±13.06µs        ? ?/sec                          1.00    301.8±3.92µs        ? ?/sec
convert_rows 4096 string(30, 0)                                                                                               1.07     78.1±0.51µs        ? ?/sec                          1.00     72.7±0.88µs        ? ?/sec
convert_rows 4096 string_dictionary(10, 0)                                                                                    1.09     66.2±1.43µs        ? ?/sec                          1.00     60.8±1.94µs        ? ?/sec
convert_rows 4096 string_dictionary(100, 0)                                                                                   1.03    114.3±0.92µs        ? ?/sec                          1.00    111.1±2.14µs        ? ?/sec
convert_rows 4096 string_dictionary(100, 0.5)                                                                                 1.06    110.2±4.02µs        ? ?/sec                          1.00    103.7±0.30µs        ? ?/sec
convert_rows 4096 string_dictionary(30, 0)                                                                                    1.08     78.4±1.43µs        ? ?/sec                          1.00     72.7±0.65µs        ? ?/sec
convert_rows 4096 string_dictionary_low_cardinality(10, 0)                                                                    1.09     66.2±1.28µs        ? ?/sec                          1.00     60.4±0.71µs        ? ?/sec
convert_rows 4096 string_dictionary_low_cardinality(100, 0)                                                                   1.04    114.5±0.64µs        ? ?/sec                          1.00    109.7±1.45µs        ? ?/sec
convert_rows 4096 string_dictionary_low_cardinality(30, 0)                                                                    1.08     78.2±0.32µs        ? ?/sec                          1.00     72.5±0.96µs        ? ?/sec
convert_rows 4096 u64(0)                                                                                                      1.04     33.1±1.79µs        ? ?/sec                          1.00     31.9±0.15µs        ? ?/sec
convert_rows 4096 u64(0.3)                                                                                                    1.02     32.7±0.35µs        ? ?/sec                          1.00     32.1±0.62µs        ? ?/sec
iterate rows                                                                                                                  1.00      2.6±0.02µs        ? ?/sec                          1.00      2.6±0.06µs        ? ?/sec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants