Skip to content

perf : Optimize count distinct#21456

Open
coderfender wants to merge 11 commits intoapache:mainfrom
coderfender:optimize_count_distinct
Open

perf : Optimize count distinct#21456
coderfender wants to merge 11 commits intoapache:mainfrom
coderfender:optimize_count_distinct

Conversation

@coderfender
Copy link
Copy Markdown
Contributor

@coderfender coderfender commented Apr 8, 2026

Which issue does this PR close?

Remove hashset based accumulators for smaller int data types and use bitmaps. Follow up of : #21453

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the functions Changes to functions implementation label Apr 8, 2026
@coderfender
Copy link
Copy Markdown
Contributor Author

coderfender commented Apr 8, 2026

benchmark results :

count_distinct i16 bitmap                      1.00      3.3±0.43µs        ? ?/sec    23.87    78.4±0.84µs        ? ?/sec
count_distinct i8 bitmap                       1.00      2.3±0.49µs        ? ?/sec    7.13     16.7±0.55µs        ? ?/sec
count_distinct u16 bitmap                      1.00      3.1±0.18µs        ? ?/sec    25.45    78.8±3.92µs        ? ?/sec
count_distinct u8 bitmap                       1.00      2.3±0.34µs        ? ?/sec    7.37     16.9±0.14µs        ? ?/sec

It seems like we are 25x faster for u16 bitmap based accumulators (or I am sleepy :) )

@Dandandan
Copy link
Copy Markdown
Contributor

I think we can do the same for 16 bit types, it is just 65_536 bytes 8192 if we use a bitmap.

@Dandandan
Copy link
Copy Markdown
Contributor

Oh wait, you're already doing that :)

@coderfender
Copy link
Copy Markdown
Contributor Author

coderfender commented Apr 8, 2026

Query 0 in clickbench_extended dataset (which uses count distinct on u8 is now ~ 11 % faster :

┃ Query     ┃    main_cb ┃ bitmap_cb_2 ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │  529.46 ms │   478.99 ms │ +1.11x faster │

(Other queries are faster but I believe that is more around variance )

┏━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃    main_cb ┃ bitmap_cb_2 ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │  529.46 ms │   478.99 ms │ +1.11x faster │
│ QQuery 1  │  107.43 ms │   102.59 ms │     no change │
│ QQuery 2  │  250.89 ms │   240.76 ms │     no change │
│ QQuery 3  │  207.67 ms │   207.49 ms │     no change │
│ QQuery 4  │  391.43 ms │   353.05 ms │ +1.11x faster │
│ QQuery 5  │ 4144.11 ms │  4084.08 ms │     no change │
│ QQuery 6  │  676.03 ms │   622.21 ms │ +1.09x faster │
│ QQuery 7  │  719.78 ms │   599.06 ms │ +1.20x faster │
│ QQuery 8  │  238.30 ms │   207.27 ms │ +1.15x faster │
│ QQuery 9  │ 1531.52 ms │  1406.34 ms │ +1.09x faster │
│ QQuery 10 │  435.27 ms │   403.28 ms │ +1.08x faster │
│ QQuery 11 │ 1043.68 ms │   955.22 ms │ +1.09x faster │
│ QQuery 12 │  113.16 ms │   106.31 ms │ +1.06x faster │
└───────────┴────────────┴─────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary          ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (main_cb)       │ 10388.73ms │
│ Total Time (bitmap_cb_2)   │  9766.66ms │
│ Average Time (main_cb)     │   799.13ms │
│ Average Time (bitmap_cb_2) │   751.28ms │
│ Queries Faster             │          9 │
│ Queries Slower             │          0 │
│ Queries with No Change     │          4 │
│ Queries with Failure       │          0 │
└────────────────────────────┴────────────┘

@coderfender
Copy link
Copy Markdown
Contributor Author

cc : @neilconway , @alamb , @martin-g . Please take a look whenever you get a chance

@alamb
Copy link
Copy Markdown
Contributor

alamb commented Apr 9, 2026

run benchmarks

@alamb alamb added the performance Make DataFusion faster label Apr 9, 2026
Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great idea. Thank you @coderfender

harness = false

[[bench]]
name = "count_distinct"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add this benchmark as a separate PR (so we can use our standard benchmark runner to confirm the results)?

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4214262367-1020-bslj7 6.12.55+ #1 SMP Sun Feb 1 08:59:41 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing optimize_count_distinct (93acd98) to 4b1901f (merge-base) diff using: tpch
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4214262367-1018-tj757 6.12.55+ #1 SMP Sun Feb 1 08:59:41 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing optimize_count_distinct (93acd98) to 4b1901f (merge-base) diff using: clickbench_partitioned
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4214262367-1019-n5fp8 6.12.55+ #1 SMP Sun Feb 1 08:59:41 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing optimize_count_distinct (93acd98) to 4b1901f (merge-base) diff using: tpcds
Results will be posted here when complete


File an issue against this benchmark runner

/// Uses 256 bytes to track all possible u8 values.
#[derive(Debug)]
pub struct BoolArray256DistinctCountAccumulator {
seen: Box<[bool; 256]>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can probably use a BooleanBuffer from Arrow to make this signifcantly faster (I think [bool uses a byte for each booelan) 🤔

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

Comparing HEAD and optimize_count_distinct
--------------------
Benchmark tpcds_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                     HEAD ┃                  optimize_count_distinct ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1  │              6.70 / 7.16 ±0.82 / 8.80 ms │              6.57 / 7.03 ±0.78 / 8.59 ms │     no change │
│ QQuery 2  │        144.90 / 145.56 ±0.51 / 146.42 ms │        144.28 / 145.34 ±0.88 / 146.73 ms │     no change │
│ QQuery 3  │        112.16 / 112.90 ±0.65 / 113.94 ms │        113.20 / 114.21 ±0.98 / 115.60 ms │     no change │
│ QQuery 4  │    1221.91 / 1256.43 ±19.64 / 1274.35 ms │    1276.83 / 1302.06 ±13.49 / 1312.76 ms │     no change │
│ QQuery 5  │        171.15 / 172.47 ±0.89 / 173.51 ms │        171.30 / 172.99 ±1.97 / 176.77 ms │     no change │
│ QQuery 6  │       817.37 / 843.23 ±20.08 / 872.86 ms │       808.55 / 844.79 ±23.63 / 872.46 ms │     no change │
│ QQuery 7  │        339.74 / 340.33 ±0.46 / 341.14 ms │        338.89 / 341.09 ±1.48 / 343.17 ms │     no change │
│ QQuery 8  │        113.46 / 115.59 ±1.38 / 117.45 ms │        114.41 / 116.14 ±1.33 / 117.70 ms │     no change │
│ QQuery 9  │        101.06 / 104.99 ±2.39 / 107.75 ms │        101.18 / 104.06 ±2.45 / 106.88 ms │     no change │
│ QQuery 10 │        103.94 / 105.87 ±1.24 / 107.25 ms │        105.29 / 105.69 ±0.39 / 106.36 ms │     no change │
│ QQuery 11 │       824.27 / 848.56 ±14.88 / 869.34 ms │        885.64 / 899.15 ±9.38 / 913.82 ms │  1.06x slower │
│ QQuery 12 │           43.36 / 45.04 ±1.41 / 46.71 ms │           43.39 / 44.87 ±0.77 / 45.52 ms │     no change │
│ QQuery 13 │        396.35 / 398.56 ±1.13 / 399.43 ms │        397.73 / 400.22 ±2.85 / 405.27 ms │     no change │
│ QQuery 14 │       985.84 / 995.59 ±6.00 / 1003.16 ms │        982.10 / 991.16 ±5.09 / 996.22 ms │     no change │
│ QQuery 15 │           15.41 / 16.07 ±0.74 / 17.41 ms │           14.73 / 16.09 ±1.58 / 19.12 ms │     no change │
│ QQuery 16 │              7.36 / 7.47 ±0.13 / 7.66 ms │              7.03 / 7.26 ±0.20 / 7.63 ms │     no change │
│ QQuery 17 │        225.56 / 228.76 ±2.32 / 232.72 ms │        224.99 / 226.62 ±1.20 / 228.25 ms │     no change │
│ QQuery 18 │        127.00 / 127.59 ±0.50 / 128.24 ms │        124.36 / 125.88 ±1.10 / 127.12 ms │     no change │
│ QQuery 19 │        152.83 / 154.64 ±1.04 / 155.73 ms │        153.97 / 155.25 ±1.03 / 156.86 ms │     no change │
│ QQuery 20 │           13.13 / 14.04 ±0.55 / 14.67 ms │           13.27 / 13.69 ±0.36 / 14.29 ms │     no change │
│ QQuery 21 │           19.15 / 19.78 ±0.64 / 20.90 ms │           18.84 / 19.28 ±0.38 / 19.93 ms │     no change │
│ QQuery 22 │        475.93 / 477.45 ±1.16 / 479.39 ms │        477.96 / 480.85 ±2.30 / 483.47 ms │     no change │
│ QQuery 23 │        858.52 / 862.56 ±4.03 / 868.13 ms │        861.18 / 863.09 ±1.95 / 866.62 ms │     no change │
│ QQuery 24 │        376.57 / 379.05 ±2.10 / 382.79 ms │        376.06 / 381.63 ±3.69 / 387.05 ms │     no change │
│ QQuery 25 │        338.49 / 339.65 ±0.84 / 340.75 ms │        335.44 / 336.83 ±1.59 / 339.88 ms │     no change │
│ QQuery 26 │           80.04 / 81.16 ±1.31 / 83.65 ms │           78.42 / 80.07 ±1.70 / 82.42 ms │     no change │
│ QQuery 27 │              6.78 / 7.35 ±0.55 / 8.13 ms │              6.96 / 7.22 ±0.19 / 7.54 ms │     no change │
│ QQuery 28 │        148.06 / 149.48 ±1.11 / 150.64 ms │        148.19 / 150.64 ±1.91 / 153.70 ms │     no change │
│ QQuery 29 │        278.08 / 280.15 ±2.08 / 284.00 ms │        276.70 / 278.24 ±1.74 / 281.35 ms │     no change │
│ QQuery 30 │           42.23 / 44.97 ±1.95 / 48.31 ms │           41.60 / 44.33 ±2.08 / 48.03 ms │     no change │
│ QQuery 31 │        168.10 / 171.06 ±2.13 / 173.56 ms │        169.08 / 171.17 ±1.71 / 172.63 ms │     no change │
│ QQuery 32 │           54.95 / 56.17 ±0.94 / 57.68 ms │           55.97 / 56.38 ±0.51 / 57.36 ms │     no change │
│ QQuery 33 │        138.83 / 141.58 ±1.51 / 142.84 ms │        137.92 / 140.02 ±1.66 / 142.01 ms │     no change │
│ QQuery 34 │              7.04 / 7.18 ±0.15 / 7.47 ms │              6.81 / 7.23 ±0.49 / 8.18 ms │     no change │
│ QQuery 35 │        104.50 / 106.03 ±1.04 / 107.13 ms │        103.81 / 106.84 ±1.60 / 108.06 ms │     no change │
│ QQuery 36 │              6.42 / 6.61 ±0.24 / 7.07 ms │              6.42 / 6.81 ±0.30 / 7.24 ms │     no change │
│ QQuery 37 │              8.14 / 8.87 ±0.47 / 9.57 ms │              8.14 / 8.53 ±0.30 / 8.92 ms │     no change │
│ QQuery 38 │           81.98 / 85.22 ±2.40 / 89.27 ms │           83.25 / 86.60 ±3.74 / 93.70 ms │     no change │
│ QQuery 39 │        121.56 / 125.29 ±2.59 / 129.24 ms │        119.98 / 123.18 ±1.81 / 124.94 ms │     no change │
│ QQuery 40 │        106.22 / 111.24 ±5.16 / 120.06 ms │        104.53 / 112.33 ±6.64 / 123.43 ms │     no change │
│ QQuery 41 │           13.97 / 14.98 ±0.67 / 15.79 ms │           14.73 / 16.12 ±1.12 / 17.51 ms │  1.08x slower │
│ QQuery 42 │        107.21 / 108.79 ±0.98 / 109.84 ms │        107.10 / 109.79 ±1.93 / 112.21 ms │     no change │
│ QQuery 43 │              5.96 / 6.27 ±0.41 / 7.06 ms │              5.93 / 6.16 ±0.14 / 6.31 ms │     no change │
│ QQuery 44 │           11.33 / 11.77 ±0.36 / 12.40 ms │           11.66 / 11.88 ±0.15 / 12.07 ms │     no change │
│ QQuery 45 │           49.83 / 50.93 ±1.07 / 52.42 ms │           49.65 / 50.38 ±1.11 / 52.58 ms │     no change │
│ QQuery 46 │              8.40 / 8.69 ±0.42 / 9.52 ms │              8.37 / 8.74 ±0.35 / 9.39 ms │     no change │
│ QQuery 47 │        668.91 / 677.76 ±6.39 / 688.74 ms │        675.58 / 678.65 ±3.07 / 684.44 ms │     no change │
│ QQuery 48 │        286.68 / 289.72 ±2.05 / 292.16 ms │        284.74 / 291.17 ±5.14 / 300.11 ms │     no change │
│ QQuery 49 │        248.22 / 254.07 ±2.98 / 256.34 ms │        249.29 / 253.34 ±2.53 / 256.18 ms │     no change │
│ QQuery 50 │        219.74 / 222.48 ±2.37 / 225.88 ms │        219.19 / 221.91 ±3.40 / 228.60 ms │     no change │
│ QQuery 51 │        178.08 / 182.02 ±2.76 / 186.40 ms │        177.56 / 180.01 ±2.33 / 184.12 ms │     no change │
│ QQuery 52 │        105.69 / 106.64 ±0.60 / 107.33 ms │        106.18 / 107.00 ±0.70 / 107.99 ms │     no change │
│ QQuery 53 │        101.05 / 101.75 ±0.57 / 102.45 ms │        100.77 / 101.74 ±0.61 / 102.48 ms │     no change │
│ QQuery 54 │        143.42 / 144.93 ±1.34 / 147.08 ms │        142.46 / 144.58 ±1.61 / 146.72 ms │     no change │
│ QQuery 55 │        105.29 / 106.91 ±1.71 / 110.21 ms │        106.15 / 108.04 ±1.73 / 110.66 ms │     no change │
│ QQuery 56 │        137.17 / 139.27 ±1.82 / 142.37 ms │        138.85 / 139.83 ±1.08 / 141.88 ms │     no change │
│ QQuery 57 │        170.13 / 173.57 ±2.62 / 177.91 ms │        166.88 / 169.00 ±1.84 / 172.44 ms │     no change │
│ QQuery 58 │        284.97 / 293.94 ±4.94 / 297.95 ms │        283.92 / 291.13 ±6.28 / 300.53 ms │     no change │
│ QQuery 59 │        194.72 / 197.24 ±1.89 / 200.37 ms │        193.80 / 199.93 ±6.67 / 212.66 ms │     no change │
│ QQuery 60 │        142.17 / 143.21 ±1.27 / 145.68 ms │        141.11 / 142.83 ±1.84 / 146.41 ms │     no change │
│ QQuery 61 │           13.32 / 13.60 ±0.32 / 14.19 ms │           12.79 / 13.11 ±0.27 / 13.55 ms │     no change │
│ QQuery 62 │       867.70 / 917.34 ±42.02 / 986.67 ms │       872.17 / 920.53 ±42.20 / 984.04 ms │     no change │
│ QQuery 63 │        101.99 / 105.69 ±2.66 / 110.01 ms │        100.66 / 104.28 ±3.54 / 110.98 ms │     no change │
│ QQuery 64 │        679.36 / 682.45 ±3.65 / 689.21 ms │        672.71 / 677.72 ±5.33 / 687.85 ms │     no change │
│ QQuery 65 │        247.01 / 248.65 ±2.10 / 252.54 ms │        244.99 / 251.19 ±4.98 / 257.31 ms │     no change │
│ QQuery 66 │        234.49 / 244.33 ±9.99 / 261.75 ms │        237.20 / 251.74 ±9.97 / 262.59 ms │     no change │
│ QQuery 67 │        301.81 / 310.27 ±7.03 / 321.48 ms │        304.34 / 314.73 ±8.11 / 325.76 ms │     no change │
│ QQuery 68 │             8.47 / 9.54 ±0.84 / 10.55 ms │             8.34 / 9.92 ±1.41 / 12.18 ms │     no change │
│ QQuery 69 │         99.97 / 101.85 ±1.69 / 104.39 ms │        100.57 / 102.21 ±1.23 / 104.08 ms │     no change │
│ QQuery 70 │       326.03 / 341.79 ±10.76 / 357.56 ms │       351.32 / 367.31 ±10.76 / 380.53 ms │  1.07x slower │
│ QQuery 71 │        132.43 / 134.32 ±1.31 / 136.44 ms │        132.84 / 135.09 ±2.63 / 138.78 ms │     no change │
│ QQuery 72 │        598.69 / 610.20 ±7.21 / 620.16 ms │        606.84 / 614.48 ±7.60 / 628.30 ms │     no change │
│ QQuery 73 │              6.58 / 7.87 ±0.80 / 9.10 ms │              6.94 / 7.62 ±0.57 / 8.45 ms │     no change │
│ QQuery 74 │        540.40 / 547.57 ±5.84 / 557.37 ms │        523.51 / 528.72 ±3.31 / 532.37 ms │     no change │
│ QQuery 75 │        274.41 / 276.28 ±1.54 / 278.66 ms │        274.00 / 275.58 ±1.34 / 277.55 ms │     no change │
│ QQuery 76 │        130.69 / 132.77 ±1.48 / 134.73 ms │        130.58 / 131.50 ±0.91 / 133.19 ms │     no change │
│ QQuery 77 │        188.21 / 189.14 ±0.81 / 190.11 ms │        185.74 / 187.25 ±1.33 / 188.85 ms │     no change │
│ QQuery 78 │        334.26 / 340.47 ±5.75 / 347.53 ms │        334.29 / 335.89 ±1.26 / 337.66 ms │     no change │
│ QQuery 79 │        230.99 / 232.56 ±1.77 / 235.99 ms │        227.68 / 231.08 ±2.73 / 235.24 ms │     no change │
│ QQuery 80 │        321.26 / 326.00 ±2.72 / 329.47 ms │        317.90 / 320.21 ±2.59 / 325.03 ms │     no change │
│ QQuery 81 │           26.56 / 27.84 ±1.63 / 30.72 ms │           25.30 / 25.97 ±0.62 / 27.00 ms │ +1.07x faster │
│ QQuery 82 │        197.83 / 200.83 ±2.49 / 203.48 ms │        197.28 / 198.18 ±0.85 / 199.69 ms │     no change │
│ QQuery 83 │           38.42 / 39.43 ±1.45 / 42.20 ms │           37.60 / 38.52 ±0.66 / 39.44 ms │     no change │
│ QQuery 84 │           47.53 / 48.47 ±0.64 / 49.46 ms │           47.35 / 48.66 ±1.05 / 50.04 ms │     no change │
│ QQuery 85 │        146.52 / 148.96 ±1.90 / 152.19 ms │        146.63 / 148.07 ±1.04 / 149.86 ms │     no change │
│ QQuery 86 │           39.18 / 40.03 ±0.74 / 40.97 ms │           38.46 / 39.79 ±0.81 / 40.96 ms │     no change │
│ QQuery 87 │           82.92 / 86.78 ±3.57 / 93.43 ms │           81.60 / 86.89 ±3.57 / 92.34 ms │     no change │
│ QQuery 88 │         99.48 / 100.49 ±0.84 / 101.60 ms │          99.19 / 99.89 ±0.63 / 101.01 ms │     no change │
│ QQuery 89 │        116.50 / 119.21 ±1.42 / 120.55 ms │        115.92 / 118.43 ±1.67 / 120.92 ms │     no change │
│ QQuery 90 │           22.93 / 23.19 ±0.26 / 23.65 ms │           23.24 / 23.41 ±0.15 / 23.63 ms │     no change │
│ QQuery 91 │           62.05 / 63.90 ±1.74 / 66.74 ms │           61.84 / 63.22 ±1.20 / 65.19 ms │     no change │
│ QQuery 92 │           56.68 / 57.75 ±0.94 / 59.18 ms │           56.53 / 57.04 ±0.50 / 57.89 ms │     no change │
│ QQuery 93 │        183.65 / 184.69 ±0.85 / 186.01 ms │        182.46 / 184.26 ±1.66 / 186.47 ms │     no change │
│ QQuery 94 │           60.28 / 60.78 ±0.39 / 61.21 ms │           59.35 / 60.53 ±1.40 / 63.17 ms │     no change │
│ QQuery 95 │        126.69 / 128.20 ±1.14 / 129.84 ms │        124.98 / 126.97 ±1.32 / 129.03 ms │     no change │
│ QQuery 96 │           73.50 / 74.85 ±1.16 / 76.65 ms │           69.34 / 72.28 ±1.70 / 74.26 ms │     no change │
│ QQuery 97 │        125.47 / 127.12 ±1.09 / 128.61 ms │        123.16 / 124.55 ±1.32 / 126.42 ms │     no change │
│ QQuery 98 │        150.24 / 153.19 ±1.54 / 154.41 ms │        152.59 / 153.93 ±1.21 / 155.88 ms │     no change │
│ QQuery 99 │ 10697.61 / 10727.70 ±35.56 / 10796.44 ms │ 10663.76 / 10709.85 ±28.50 / 10741.16 ms │     no change │
└───────────┴──────────────────────────────────────────┴──────────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                      ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                      │ 30922.74ms │
│ Total Time (optimize_count_distinct)   │ 30987.69ms │
│ Average Time (HEAD)                    │   312.35ms │
│ Average Time (optimize_count_distinct) │   313.01ms │
│ Queries Faster                         │          1 │
│ Queries Slower                         │          3 │
│ Queries with No Change                 │         95 │
│ Queries with Failure                   │          0 │
└────────────────────────────────────────┴────────────┘

Resource Usage

tpcds — base (merge-base)

Metric Value
Wall time 154.9s
Peak memory 5.5 GiB
Avg memory 4.6 GiB
CPU user 255.6s
CPU sys 16.7s
Peak spill 0 B

tpcds — branch

Metric Value
Wall time 155.2s
Peak memory 5.6 GiB
Avg memory 4.6 GiB
CPU user 256.2s
CPU sys 16.1s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

Comparing HEAD and optimize_count_distinct
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                  HEAD ┃               optimize_count_distinct ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │          1.23 / 4.48 ±6.36 / 17.20 ms │          1.26 / 4.62 ±6.52 / 17.66 ms │     no change │
│ QQuery 1  │        14.33 / 14.82 ±0.28 / 15.07 ms │        14.46 / 14.97 ±0.27 / 15.24 ms │     no change │
│ QQuery 2  │        43.90 / 44.28 ±0.23 / 44.62 ms │        44.77 / 45.23 ±0.31 / 45.53 ms │     no change │
│ QQuery 3  │        42.81 / 45.34 ±1.63 / 47.72 ms │        43.14 / 46.60 ±2.49 / 49.31 ms │     no change │
│ QQuery 4  │     297.63 / 303.10 ±4.26 / 308.88 ms │     300.83 / 309.13 ±5.13 / 316.33 ms │     no change │
│ QQuery 5  │     345.39 / 359.62 ±9.64 / 373.03 ms │     356.21 / 360.33 ±3.42 / 366.21 ms │     no change │
│ QQuery 6  │           5.80 / 6.56 ±0.60 / 7.19 ms │           5.88 / 6.65 ±0.66 / 7.73 ms │     no change │
│ QQuery 7  │        17.18 / 18.14 ±0.93 / 19.50 ms │        16.82 / 18.06 ±1.11 / 19.71 ms │     no change │
│ QQuery 8  │     440.03 / 446.40 ±6.36 / 456.83 ms │     424.75 / 433.54 ±6.18 / 439.73 ms │     no change │
│ QQuery 9  │     679.76 / 689.70 ±7.53 / 698.21 ms │    657.41 / 672.75 ±12.70 / 692.01 ms │     no change │
│ QQuery 10 │        90.59 / 94.51 ±3.10 / 99.98 ms │       92.25 / 96.06 ±3.82 / 102.91 ms │     no change │
│ QQuery 11 │     102.83 / 105.14 ±1.74 / 107.56 ms │     104.10 / 104.90 ±0.66 / 105.56 ms │     no change │
│ QQuery 12 │     349.97 / 354.94 ±5.98 / 366.21 ms │     347.11 / 351.71 ±4.19 / 359.38 ms │     no change │
│ QQuery 13 │    458.92 / 473.76 ±12.15 / 490.75 ms │     481.51 / 493.37 ±9.76 / 508.87 ms │     no change │
│ QQuery 14 │     348.02 / 350.16 ±1.34 / 351.67 ms │     356.38 / 364.56 ±5.60 / 371.39 ms │     no change │
│ QQuery 15 │    362.57 / 375.82 ±10.29 / 393.65 ms │    369.40 / 384.95 ±12.68 / 403.51 ms │     no change │
│ QQuery 16 │    736.29 / 762.68 ±24.80 / 800.53 ms │    721.30 / 736.84 ±18.59 / 769.51 ms │     no change │
│ QQuery 17 │     719.71 / 726.38 ±6.28 / 736.74 ms │    719.36 / 737.33 ±20.12 / 773.17 ms │     no change │
│ QQuery 18 │ 1460.56 / 1494.33 ±28.92 / 1543.92 ms │ 1460.13 / 1516.78 ±38.19 / 1578.59 ms │     no change │
│ QQuery 19 │       36.11 / 47.46 ±20.66 / 88.75 ms │        36.35 / 36.83 ±0.48 / 37.75 ms │ +1.29x faster │
│ QQuery 20 │    731.41 / 747.31 ±13.86 / 770.87 ms │    717.45 / 731.86 ±18.25 / 767.37 ms │     no change │
│ QQuery 21 │     765.02 / 774.36 ±6.10 / 782.06 ms │     761.04 / 766.09 ±5.26 / 775.66 ms │     no change │
│ QQuery 22 │  1138.03 / 1142.93 ±5.94 / 1152.75 ms │  1140.79 / 1150.64 ±8.15 / 1159.10 ms │     no change │
│ QQuery 23 │ 3118.79 / 3156.67 ±40.21 / 3232.13 ms │ 3102.03 / 3134.12 ±23.45 / 3165.78 ms │     no change │
│ QQuery 24 │     100.36 / 105.00 ±3.10 / 109.33 ms │     101.91 / 104.92 ±2.28 / 107.26 ms │     no change │
│ QQuery 25 │     144.88 / 146.36 ±1.83 / 149.79 ms │     141.22 / 143.54 ±1.71 / 145.67 ms │     no change │
│ QQuery 26 │     105.31 / 107.86 ±1.44 / 109.40 ms │     101.16 / 103.09 ±0.97 / 103.70 ms │     no change │
│ QQuery 27 │    853.30 / 873.97 ±11.92 / 889.57 ms │     849.45 / 856.26 ±8.03 / 871.41 ms │     no change │
│ QQuery 28 │ 7734.58 / 7797.79 ±32.49 / 7824.51 ms │ 7730.70 / 7803.25 ±40.00 / 7851.14 ms │     no change │
│ QQuery 29 │        50.23 / 57.29 ±9.06 / 74.82 ms │        51.48 / 54.97 ±3.39 / 61.08 ms │     no change │
│ QQuery 30 │     372.50 / 379.04 ±4.07 / 384.25 ms │     366.70 / 375.13 ±5.86 / 384.04 ms │     no change │
│ QQuery 31 │     383.84 / 399.29 ±9.29 / 411.02 ms │    374.83 / 387.64 ±12.34 / 411.22 ms │     no change │
│ QQuery 32 │ 1206.33 / 1289.29 ±63.58 / 1398.46 ms │ 1046.98 / 1065.04 ±18.32 / 1098.58 ms │ +1.21x faster │
│ QQuery 33 │ 1518.56 / 1544.14 ±28.90 / 1599.86 ms │ 1489.80 / 1525.69 ±28.39 / 1555.99 ms │     no change │
│ QQuery 34 │ 1495.67 / 1511.19 ±15.41 / 1540.41 ms │ 1484.30 / 1578.62 ±78.46 / 1700.12 ms │     no change │
│ QQuery 35 │     401.31 / 405.37 ±4.32 / 413.61 ms │    426.40 / 460.44 ±25.53 / 496.38 ms │  1.14x slower │
│ QQuery 36 │     112.93 / 122.76 ±5.30 / 128.84 ms │     130.31 / 137.48 ±9.58 / 156.35 ms │  1.12x slower │
│ QQuery 37 │        48.96 / 50.00 ±1.27 / 52.45 ms │        49.08 / 50.89 ±1.84 / 53.54 ms │     no change │
│ QQuery 38 │        76.49 / 77.05 ±0.55 / 77.80 ms │        85.27 / 88.84 ±1.91 / 90.47 ms │  1.15x slower │
│ QQuery 39 │     213.03 / 218.46 ±3.51 / 222.55 ms │     238.03 / 242.76 ±4.43 / 251.04 ms │  1.11x slower │
│ QQuery 40 │        24.42 / 26.08 ±1.84 / 29.65 ms │        23.41 / 28.89 ±5.28 / 38.52 ms │  1.11x slower │
│ QQuery 41 │        21.30 / 23.11 ±1.51 / 25.35 ms │        20.94 / 23.92 ±3.25 / 30.11 ms │     no change │
│ QQuery 42 │        19.91 / 20.52 ±0.43 / 21.11 ms │        19.96 / 20.91 ±0.68 / 21.98 ms │     no change │
└───────────┴───────────────────────────────────────┴───────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                      ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                      │ 27693.44ms │
│ Total Time (optimize_count_distinct)   │ 27570.21ms │
│ Average Time (HEAD)                    │   644.03ms │
│ Average Time (optimize_count_distinct) │   641.17ms │
│ Queries Faster                         │          2 │
│ Queries Slower                         │          5 │
│ Queries with No Change                 │         36 │
│ Queries with Failure                   │          0 │
└────────────────────────────────────────┴────────────┘

Resource Usage

clickbench_partitioned — base (merge-base)

Metric Value
Wall time 139.6s
Peak memory 39.7 GiB
Avg memory 29.0 GiB
CPU user 1314.1s
CPU sys 99.0s
Peak spill 0 B

clickbench_partitioned — branch

Metric Value
Wall time 138.4s
Peak memory 39.0 GiB
Avg memory 31.1 GiB
CPU user 1312.3s
CPU sys 93.5s
Peak spill 0 B

File an issue against this benchmark runner

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

Labels

functions Changes to functions implementation performance Make DataFusion faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use bitmap for count_distinct expression for u8/16 and i8/16 [perf]

4 participants