alamb commented on PR #24687:
URL: https://github.com/apache/datafusion/pull/24687#issuecomment-5424315287

   ## Benchmark and code size results
   
   Measured on macOS (Apple Silicon), comparing this branch against the #24102 
branch (criterion baseline), `cargo bench -p datafusion-physical-expr --bench 
in_list_strategy -- fixed_size_binary`.
   
   ### Runtime (dynamic dispatch vs monomorphized)
   
   | Benchmark | Time (this PR) | Change vs #24102 | Verdict |
   |---|---:|---:|---|
   | `fsb1/list=16/match=0%` | 3.23 µs | +0.05% | no change (p=0.82) |
   | `fsb1/list=16/match=50%` | 3.23 µs | +0.67% | |
   | `fsb2/list=64/match=0%` | 3.16 µs | +0.93% | |
   | `fsb2/list=64/match=50%` | 3.18 µs | +1.83% | |
   | `fsb16/list=4/match=0%` | 7.74 µs | −1.12% | improved |
   | `fsb16/list=4/match=50%` | 7.86 µs | +0.50% | no change (p=0.19) |
   | `fsb16/list=64/match=0%` | 11.70 µs | +3.21% | regressed |
   | `fsb16/list=64/match=50%` | 12.89 µs | +1.43% | |
   | `fsb16/list=256/match=0%` | 11.50 µs | −0.05% | no change (p=0.82) |
   | `fsb16/list=256/match=50%` | 12.98 µs | +1.37% | |
   | `fsb16/list=10000/match=0%` | 11.30 µs | −2.23% | improved |
   | `fsb16/list=10000/match=50%` | 13.61 µs | −1.20% | |
   | `fsb16/list=64/match=0%/unaligned` | 14.62 µs | −2.13% | improved |
   | `fsb16/list=64/match=50%/unaligned` | 16.50 µs | +1.21% | |
   
   All differences are within ±3.2% and roughly symmetric around zero (some 
faster, some slower), so the per-batch runtime dispatch cost is in the noise. 
This makes sense: the dispatch is one `match` on `value_size()` per batch (8192 
rows), amortized to ~fractions of a nanosecond per row.
   
   ### Code size
   
   `cargo llvm-lines --release -p datafusion-physical-expr --lib`, functions in 
the `fixed_size_binary_filter` module:
   
   | Metric | #24102 (generic) | This PR (runtime dispatch) | Change |
   |---|---:|---:|---:|
   | Module LLVM IR lines | 14,803 | 4,912 | **−67%** |
   | Module function instantiations | 46 | 14 | −70% |
   | Crate total IR lines | 1,356,668 | 1,346,777 | −9,891 (−0.7%) |
   | `in_list_strategy` bench binary size | 12,133,952 B | 12,100,912 B | −33 
KB (−0.27%) |
   
   The generic version emits 5 copies of `FixedSizeBinaryFilter::<T>::contains` 
(~1,800 IR lines each) plus 5 copies each of `instantiate_for_primitive` and 
its closures. The runtime-dispatch version keeps only the 5 small 
`reinterpret_as_primitive::<T>` instantiations (~350 lines each, which do the 
actual width-specific buffer work) and collapses everything else to single 
copies — matching the "about 1/3 of the code gen" estimate in 
https://github.com/apache/datafusion/pull/24102#discussion_r3851941679.
   
   ### Conclusion
   
   Runtime dispatch removes ~2/3 of the generated code for this module with no 
measurable runtime cost.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to