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

exec: handle nulls in AVG aggregator #38828

Merged
merged 1 commit into from
Jul 11, 2019

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Jul 11, 2019

closes #37738

The random aggregation test uses float64 now so that AVG can be included in this test, until #38823 can be addressed.

BenchmarkAggregator/AVG/hash/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-12       	      20	  72817604 ns/op	   7.20 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-12        	      20	  67807960 ns/op	   7.73 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-12       	      30	  45907478 ns/op	  11.42 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-12        	      30	  44468409 ns/op	  11.79 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-12     	     200	   8712009 ns/op	  60.18 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-12      	     200	   8852871 ns/op	  59.22 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-12    	     200	   9058353 ns/op	  57.88 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-12     	     200	   9289322 ns/op	  56.44 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-12    	      20	  67161015 ns/op	   7.81 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-12     	      20	  60712202 ns/op	   8.64 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-12    	      30	  40953924 ns/op	  12.80 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-12     	      30	  39335420 ns/op	  13.33 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-12  	     300	   4201872 ns/op	 124.77 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-12   	     300	   4202353 ns/op	 124.76 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-12 	     500	   3982187 ns/op	 131.66 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-12  	     500	   3766494 ns/op	 139.20 MB/s

Release note: None

BenchmarkAggregator/AVG/hash/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-12       	      20	  72817604 ns/op	   7.20 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-12        	      20	  67807960 ns/op	   7.73 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-12       	      30	  45907478 ns/op	  11.42 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-12        	      30	  44468409 ns/op	  11.79 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-12     	     200	   8712009 ns/op	  60.18 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-12      	     200	   8852871 ns/op	  59.22 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-12    	     200	   9058353 ns/op	  57.88 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-12     	     200	   9289322 ns/op	  56.44 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-12    	      20	  67161015 ns/op	   7.81 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-12     	      20	  60712202 ns/op	   8.64 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-12    	      30	  40953924 ns/op	  12.80 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-12     	      30	  39335420 ns/op	  13.33 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-12  	     300	   4201872 ns/op	 124.77 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-12   	     300	   4202353 ns/op	 124.76 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-12 	     500	   3982187 ns/op	 131.66 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-12  	     500	   3766494 ns/op	 139.20 MB/s

Release note: None
@rafiss rafiss requested review from solongordon and a team July 11, 2019 19:53
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss
Copy link
Collaborator Author

rafiss commented Jul 11, 2019

Thanks to a few of the lessons learned from implementing the other aggregators, the benchmark stats are actually better with null handling than without.

name                                                                                old time/op    new time/op    delta
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-24        206ms ± 1%     111ms ± 0%   -46.19%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-24         206ms ± 1%     100ms ± 1%   -51.27%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-24        148ms ± 1%      68ms ± 1%   -54.00%  (p=0.000 n=9+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-24         148ms ± 1%      65ms ± 1%   -55.97%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-24     23.1ms ± 3%     6.7ms ± 2%   -71.01%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-24      23.1ms ± 2%     6.6ms ± 1%   -71.31%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-24    14.8ms ± 2%     6.2ms ± 0%   -58.08%  (p=0.000 n=10+9)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-24     15.1ms ± 2%     6.0ms ± 1%   -60.37%  (p=0.000 n=10+9)

name                                                                                old speed      new speed      delta
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-24     2.55MB/s ± 1%  4.74MB/s ± 0%   +85.69%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-24      2.55MB/s ± 1%  5.23MB/s ± 1%  +105.26%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-24     3.53MB/s ± 0%  7.70MB/s ± 1%  +117.96%  (p=0.000 n=7+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-24      3.54MB/s ± 1%  8.03MB/s ± 1%  +127.12%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-24   22.7MB/s ± 3%  78.4MB/s ± 2%  +244.90%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-24    22.7MB/s ± 2%  79.0MB/s ± 1%  +248.50%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-24  35.4MB/s ± 2%  84.3MB/s ± 0%  +138.51%  (p=0.000 n=10+9)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-24   34.8MB/s ± 3%  87.7MB/s ± 1%  +152.28%  (p=0.000 n=10+9)

name                                                                                old alloc/op   new alloc/op   delta
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-24       29.0MB ± 0%    15.2MB ± 0%   -47.71%  (p=0.000 n=9+10)
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-24        29.0MB ± 0%    13.6MB ± 0%   -52.91%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-24       19.6MB ± 0%     9.2MB ± 0%   -52.96%  (p=0.000 n=9+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-24        19.6MB ± 0%     8.8MB ± 0%   -54.89%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-24      943kB ± 0%      85kB ± 0%   -90.95%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-24       943kB ± 0%      91kB ± 0%   -90.30%  (p=0.000 n=7+10)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-24     489kB ± 0%      67kB ± 0%   -86.23%  (p=0.000 n=9+10)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-24      489kB ± 0%      70kB ± 0%   -85.60%  (p=0.000 n=10+8)

name                                                                                old allocs/op  new allocs/op  delta
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-24        1.04M ± 0%     0.59M ± 0%   -43.29%  (p=0.000 n=9+10)
Aggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-24         1.04M ± 0%     0.53M ± 0%   -48.95%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-24         664k ± 0%      328k ± 0%   -50.61%  (p=0.000 n=9+10)
Aggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-24          664k ± 0%      319k ± 0%   -52.01%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-24      29.7k ± 0%      1.9k ± 0%   -93.51%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-24       29.7k ± 0%      2.1k ± 0%   -93.08%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-24     15.0k ± 0%      1.3k ± 0%   -91.39%  (p=0.000 n=10+10)
Aggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-24      15.0k ± 0%      1.4k ± 0%   -90.96%  (p=0.000 n=10+8)

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice to see the benchmark improvements!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @solongordon)

@rafiss
Copy link
Collaborator Author

rafiss commented Jul 11, 2019

💯
bors r+

craig bot pushed a commit that referenced this pull request Jul 11, 2019
38828: exec: handle nulls in AVG aggregator r=rafiss a=rafiss

closes #37738 

The random aggregation test uses float64 now so that AVG can be included in this test, until #38823 can be addressed.

```
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-12       	      20	  72817604 ns/op	   7.20 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-12        	      20	  67807960 ns/op	   7.73 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-12       	      30	  45907478 ns/op	  11.42 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-12        	      30	  44468409 ns/op	  11.79 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-12     	     200	   8712009 ns/op	  60.18 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-12      	     200	   8852871 ns/op	  59.22 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-12    	     200	   9058353 ns/op	  57.88 MB/s
BenchmarkAggregator/AVG/hash/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-12     	     200	   9289322 ns/op	  56.44 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=false/numInputBatches=64-12    	      20	  67161015 ns/op	   7.81 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1/hasNulls=true/numInputBatches=64-12     	      20	  60712202 ns/op	   8.64 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=false/numInputBatches=64-12    	      30	  40953924 ns/op	  12.80 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=2/hasNulls=true/numInputBatches=64-12     	      30	  39335420 ns/op	  13.33 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=false/numInputBatches=64-12  	     300	   4201872 ns/op	 124.77 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=512/hasNulls=true/numInputBatches=64-12   	     300	   4202353 ns/op	 124.76 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=false/numInputBatches=64-12 	     500	   3982187 ns/op	 131.66 MB/s
BenchmarkAggregator/AVG/ordered/Decimal/groupSize=1024/hasNulls=true/numInputBatches=64-12  	     500	   3766494 ns/op	 139.20 MB/s
```

Release note: None

Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jul 11, 2019

Build succeeded

@craig craig bot merged commit dbc93bd into cockroachdb:master Jul 11, 2019
@rafiss rafiss deleted the avg-aggregator-null-handling branch July 12, 2019 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exec: aggregations don't handle nulls
3 participants