mbutrovich commented on PR #12137:
URL: https://github.com/apache/arrow-rs/pull/12137#issuecomment-6747463559

   Closing this. None of the designs I tried fixed #12136 without a cost, so 
I'll bring the results to #11879 instead of keeping a second PR open.
   
   The Apple M5 Max numbers in the description didn't hold on the bot's CPUs. 
Here is each design on the Xeon Platinum 8581C. Speedup is the time at 
7cfa2d13ad (`main` plus the benchmark commit) over the time at each commit:
   
   | Commit | Design | `append`, all false | `append`, all true | `append`, 
random | Short and 8-value `append_slice` | Run |
   |---|---|---|---|---|---|---|
   | 9cd3685a9d | One read-modify-write per value, no branch | 0.37x | 0.88x | 
1.95x | 0.93x to 0.98x | 
https://github.com/apache/arrow-rs/pull/12137#issuecomment-6745382116 |
   | fee5a03a5b | Dirty flag checked in `advance` | 0.70x | 1.01x | 0.90x | 
0.86x to 0.91x | 
https://github.com/apache/arrow-rs/pull/12137#issuecomment-6746130334 |
   | 3121d3e659 | Flag, clear marked `#[cold]` | 0.86x | 1.00x | 0.92x | 0.87x 
to 0.91x | 
https://github.com/apache/arrow-rs/pull/12137#issuecomment-6746987152 |
   | 32fbb333e4 | Flag, clear marked `#[cold]` and `#[inline(never)]` | 0.83x | 
1.01x | 0.82x | 0.97x to 1.00x | 
https://github.com/apache/arrow-rs/pull/12137#issuecomment-6747325134 |
   
   Each row came from a separate run. Bulk `append_slice`, which none of these 
change, stayed between 0.96x and 1.05x in every run.
   
   The branchless write makes each `append` wait for the previous value's store 
to the same byte. It wins on random values (1.95x on the Xeon and 2.25x on 
Neoverse-V2) and loses on constant ones (0.37x and 0.67x on all false). The 
flag costs a load and a branch on every append, which comes to about 0.85x on 
all false in a loop that does nothing else. With only `#[cold]`, LLVM still 
inlined the clear, and under thin LTO with 16 codegen units `append_slice` 
stopped inlining into its callers. `#[inline(never)]` fixed that.
   


-- 
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]

Reply via email to