mbutrovich commented on PR #9683: URL: https://github.com/apache/arrow-rs/pull/9683#issuecomment-4218875737
I tried the 4 optimizations you suggested, and here are the results: | Schema, N | Before | After | Change | |---|---|---|---| | [i32, i32_opt], 4096 | 71.987 µs | 70.200 µs | -2.5% | | [i32, i32_opt], 32768 | 359.07 µs | 341.22 µs | -5.0% | | [i32, str_opt(16)], 4096 | 88.564 µs | 88.874 µs | +0.4% | | [i32, str_opt(16)], 32768 | 510.93 µs | 493.01 µs | -3.5% | | [i32, str(16)], 4096 | 85.021 µs | 92.958 µs | +9.3% | | [i32, str(16)], 32768 | 457.38 µs | 425.87 µs | -6.9% | | [str_opt(16), str(16)], 4096 | 123.71 µs | 133.51 µs | +7.9% | | [str_opt(16), str(16)], 32768 | 946.89 µs | 993.63 µs | +4.9% | | [str_opt(16), str_opt(50), str(16)], 4096 | 155.40 µs | 165.69 µs | +6.6% | | [str_opt(16), str_opt(50), str(16)], 32768 | 1.2148 ms | 1.2654 ms | +4.2% | | [str_opt(16), str(16), str_opt(16), str_opt(16), str_opt(16)], 4096 | 188.98 µs | 199.13 µs | +5.4% | | [str_opt(16), str(16), str_opt(16), str_opt(16), str_opt(16)], 32768 | 1.5222 ms | 1.5486 ms | +1.7% | | [i32_opt, dict(100,str_opt(50))], 4096 | 100.16 µs | 101.17 µs | +1.0% | | [i32_opt, dict(100,str_opt(50))], 32768 | 627.81 µs | 686.16 µs | +9.3% | | [dict(100,str_opt(50)), dict(100,str_opt(50))], 4096 | 90.044 µs | 89.670 µs | -0.4% | | [dict(100,str_opt(50)), dict(100,str_opt(50))], 32768 | 722.44 µs | 741.11 µs | +2.6% | | [dict(100,str_opt(50))x3, str(16)], 4096 | 179.50 µs | 187.09 µs | +4.2% | | [dict(100,str_opt(50))x3, str(16)], 32768 | 1.5303 ms | 1.5696 ms | +2.6% | | [dict(100,str_opt(50))x3, str_opt(50)], 4096 | 192.86 µs | 200.81 µs | +4.1% | | [dict(100,str_opt(50))x3, str_opt(50)], 32768 | 1.7082 ms | 1.7309 ms | +1.3% | | [i32_opt, i32_list], 4096 | 157.57 µs | 160.09 µs | +1.6% | | [i32_opt, i32_list], 32768 | 1.3393 ms | 1.4233 ms | +6.3% | | [i32_opt, i32_list_opt], 4096 | 161.53 µs | 164.17 µs | +1.6% | | [i32_opt, i32_list_opt], 32768 | 1.3731 ms | 1.4992 ms | +9.2% | | [i32_list_opt, i32_opt], 4096 | 173.67 µs | 179.41 µs | +3.3% | | [i32_list_opt, i32_opt], 32768 | 1.5963 ms | 1.5744 ms | -1.4% | | [i32, str_list(4)], 4096 | 287.85 µs | 291.31 µs | +1.2% | | [i32, str_list(4)], 32768 | 3.3054 ms | 3.2674 ms | -1.1% | | [str_list(4), i32], 4096 | 297.47 µs | 360.26 µs | +21.1% | | [str_list(4), i32], 32768 | 3.8276 ms | 3.8494 ms | +0.6% | | [i32, str_list_opt(4)], 4096 | 261.91 µs | 325.47 µs | +24.3% | | [i32, str_list_opt(4)], 32768 | 3.1478 ms | 3.1075 ms | -1.3% | | [str_list_opt(4), i32], 4096 | 300.98 µs | 334.20 µs | +11.0% | | [str_list_opt(4), i32], 32768 | 3.7982 ms | 3.8360 ms | +1.0% | | [i32, i32_list, str(16)], 4096 | 170.03 µs | 175.74 µs | +3.4% | | [i32, i32_list, str(16)], 32768 | 1.1633 ms | 1.1742 ms | +0.9% | | [i32_opt, i32_list_opt, str_opt(50)], 4096 | 195.77 µs | 198.17 µs | +1.2% | | [i32_opt, i32_list_opt, str_opt(50)], 32768 | 1.6350 ms | 1.7419 ms | +6.5% | Claude's attempt at interpreting the results: > Integer schemas at large N improved ~3-5%. Most other schemas regressed, especially list-leading schemas at small N (+21-24%). > > **Likely causes**: > 1. **Ping-pong fallback overhead**: The old code did one bulk `copy_from_slice` per level. Ping-pong eliminates that but replaces it with many small per bucket copies in the fallback path. For schemas that produce many small buckets (strings, lists, dicts), many scattered copies are less efficient than one contiguous memcpy. > 2. **`data_from` comparison overhead**: The old fallback used `ra.cmp(&rb)` — a direct memcmp. The new `data_from(byte_pos).cmp(...)` adds a bounds check + subslice per row per comparison. For schemas hitting the fallback frequently, this outweighs the benefit of skipping the shared prefix. > > Integer schemas benefit because they have fewer, larger buckets that stay in the radix path longer where the eliminated per-level memcpy pays off. Do you want the commit anyway just to iterate off of? -- 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]
