korowa commented on PR #8721: URL: https://github.com/apache/arrow-datafusion/pull/8721#issuecomment-1876857555
UPD: after the comment by @Dandandan, regarding implementation of groups accumulator, I've realized that it's unclear (as for me) now how to implement it decently, and in the same time naive implementation will still require non-zero efforts to support it. In the same time, performance improvement mostly comes from replacement of `ScalarValue` with native types, so I've reworked regular accumulators in this PR -- this way it should be more meaningful and less stressful change. The results for clickbench for updated branch: ``` -------------------- Benchmark clickbench_1.json -------------------- ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓ ┃ Query ┃ master ┃ count_distinct_groups_accumulator ┃ Change ┃ ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩ │ QQuery 0 │ 1.99ms │ 2.32ms │ 1.16x slower │ │ QQuery 1 │ 85.49ms │ 89.27ms │ no change │ │ QQuery 2 │ 212.14ms │ 209.42ms │ no change │ │ QQuery 3 │ 238.46ms │ 236.34ms │ no change │ │ QQuery 4 │ 2073.40ms │ 2073.13ms │ no change │ │ QQuery 5 │ 3046.88ms │ 3027.83ms │ no change │ │ QQuery 6 │ 81.46ms │ 83.87ms │ no change │ │ QQuery 7 │ 93.53ms │ 88.94ms │ no change │ │ QQuery 8 │ 3325.04ms │ 3377.85ms │ no change │ │ QQuery 9 │ 5072.76ms │ 2203.71ms │ +2.30x faster │ │ QQuery 10 │ 755.97ms │ 722.47ms │ no change │ │ QQuery 11 │ 833.25ms │ 792.76ms │ no change │ │ QQuery 12 │ 2778.89ms │ 2750.02ms │ no change │ │ QQuery 13 │ 5375.29ms │ 5333.02ms │ no change │ │ QQuery 14 │ 3042.31ms │ 3083.98ms │ no change │ │ QQuery 15 │ 2317.14ms │ 2419.19ms │ no change │ │ QQuery 16 │ 6438.85ms │ 6467.34ms │ no change │ │ QQuery 17 │ 5956.24ms │ 6179.98ms │ no change │ │ QQuery 18(x) │ 0.23ms │ 0.18ms │ +1.30x faster │ │ QQuery 19 │ 201.02ms │ 197.43ms │ no change │ │ QQuery 20 │ 3383.48ms │ 3499.00ms │ no change │ │ QQuery 21 │ 4334.13ms │ 4305.25ms │ no change │ │ QQuery 22 │ 10960.44ms │ 11275.28ms │ no change │ │ QQuery 23 │ 27659.63ms │ 28158.01ms │ no change │ │ QQuery 24 │ 1445.17ms │ 1470.58ms │ no change │ │ QQuery 25 │ 1218.96ms │ 1234.64ms │ no change │ │ QQuery 26 │ 1586.36ms │ 1584.74ms │ no change │ │ QQuery 27 │ 4713.18ms │ 4795.20ms │ no change │ │ QQuery 28 │ 31076.60ms │ 30640.46ms │ no change │ │ QQuery 29 │ 1253.69ms │ 1190.34ms │ +1.05x faster │ │ QQuery 30 │ 2687.34ms │ 2667.62ms │ no change │ │ QQuery 31 │ 3511.00ms │ 3653.13ms │ no change │ │ QQuery 32(x) │ 0.19ms │ 0.18ms │ no change │ │ QQuery 33(x) │ 0.17ms │ 0.16ms │ no change │ │ QQuery 34(x) │ 0.16ms │ 0.15ms │ +1.09x faster │ │ QQuery 35 │ 3828.87ms │ 3870.08ms │ no change │ │ QQuery 36 │ 332.74ms │ 332.81ms │ no change │ │ QQuery 37 │ 191.57ms │ 175.67ms │ +1.09x faster │ │ QQuery 38 │ 167.19ms │ 159.98ms │ no change │ │ QQuery 39 │ 778.11ms │ 781.46ms │ no change │ │ QQuery 40 │ 81.00ms │ 81.00ms │ no change │ │ QQuery 41 │ 71.14ms │ 69.90ms │ no change │ │ QQuery 42 │ 78.41ms │ 70.35ms │ +1.11x faster │ └──────────────┴────────────┴───────────────────────────────────┴───────────────┘ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓ ┃ Benchmark Summary ┃ ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩ │ Total Time (master) │ 141289.87ms │ │ Total Time (count_distinct_groups_accumulator) │ 139355.04ms │ │ Average Time (master) │ 3285.81ms │ │ Average Time (count_distinct_groups_accumulator) │ 3240.81ms │ │ Queries Faster │ 6 │ │ Queries Slower │ 1 │ │ Queries with No Change │ 36 │ └──────────────────────────────────────────────────┴─────────────┘ ``` >The target query was clickbench q9 -- there are not so many queries where DF plans groups accumulator for count distinct. (x) marked queries were constantly killed by OOM on my laptop, so they were replaced with dummy select 1; (there are no count distinct queries among them). Also works here -- 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]
