Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of standard deviation aggregate #824

Open
andygrove opened this issue Aug 13, 2024 · 2 comments
Open

Improve performance of standard deviation aggregate #824

andygrove opened this issue Aug 13, 2024 · 2 comments
Labels
enhancement New feature or request performance
Milestone

Comments

@andygrove
Copy link
Member

What is the problem the feature request solves?

I am benchmarking with this query (based on TPC-DS q39):

select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
     ,stddev_samp(inv_quantity_on_hand) stdev
from inventory
   ,item
   ,warehouse
   ,date_dim
where inv_item_sk = i_item_sk
  and inv_warehouse_sk = w_warehouse_sk
  and inv_date_sk = d_date_sk
  and d_year =2001
group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy;

Results:

AMD Ryzen 9 7950X3D 16-Core Processor
TPCDS Micro Benchmarks:                   Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
stddev                                             3295           3370         105         40.4          24.7       1.0X
stddev: Comet (Scan)                               3343           3461         167         39.9          25.1       1.0X
stddev: Comet (Scan, Exec)                         7621           7657          50         17.5          57.2       0.4X

If I change the query to use avg instead of stddev then I get much better results (ignore the benchmark name):

AMD Ryzen 9 7950X3D 16-Core Processor
TPCDS Micro Benchmarks:                   Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
stddev                                             3187           3276         125         41.8          23.9       1.0X
stddev: Comet (Scan)                               3128           3163          48         42.6          23.5       1.0X
stddev: Comet (Scan, Exec)                         2209           2241          44         60.3          16.6       1.4X

Describe the potential solution

No response

Additional context

No response

@eejbyfeldt
Copy link
Contributor

eejbyfeldt commented Aug 21, 2024

I suspect that implementing the GroupsAccumulator api could resolve this. Took a stab at implementing it here: apache/datafusion#12095 (issue: apache/datafusion#12094) in datafusion. This can the easily be replicated in our version of the aggregates.

@andygrove
Copy link
Member Author

Thank you @eejbyfeldt

@andygrove andygrove self-assigned this Sep 4, 2024
@andygrove andygrove added this to the 0.3.0 milestone Sep 16, 2024
@andygrove andygrove modified the milestones: 0.3.0, 0.4.0 Sep 24, 2024
@andygrove andygrove removed their assignment Oct 31, 2024
@andygrove andygrove modified the milestones: 0.4.0, 0.5.0 Nov 11, 2024
@andygrove andygrove modified the milestones: 0.5.0, 0.6.0 Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Projects
None yet
Development

No branches or pull requests

2 participants