Skip to content

Improve performance of aggregation operator#19425

Draft
fgwang7w wants to merge 8 commits intoprestodb:masterfrom
fgwang7w:optimizemultichannelgroupby
Draft

Improve performance of aggregation operator#19425
fgwang7w wants to merge 8 commits intoprestodb:masterfrom
fgwang7w:optimizemultichannelgroupby

Conversation

@fgwang7w
Copy link
Member

@fgwang7w fgwang7w commented Apr 18, 2023

Reduce large long[] memory usage and Improve Group-by performance

== RELEASE NOTES ==

General Changes
* Improve performance of aggregation operator

For memory optimization:

  • Avoid allocating huge long bytes for MultiChannelGroupByHash.

image

e.g we are looking at 64MB of long[] bytes * 15 = 960MB that can be avoided for memory allocation

image

Cherry-pick of trinodb/trino#9514
Cherry-pick of trinodb/trino#10965
Cherry-pick of trinodb/trino#12336
Cherry-pick of trinodb/trino#12597

Test Result: (sample query from tpcds-q10 with multiple grouping sets)
Before:
Peak User Memory | 11.37MB
Peak Total Memory | 78.63MB
Elapsed Time | 7.68s

After:
Peak User Memory | 5.65MB
Peak Total Memory | 61.71MB
Elapsed Time | 2.08s

Performance test on TPC-H 1TB benchmark:

query before(ms) after(ms) Performance gain
presto/tpch/q06.sql 14495 13890 4.17%
presto/tpch/q10.sql 53888 38592 28.39%
presto/tpch/q17.sql 95613 91107 4.71%
presto/tpch/q20.sql 38565 34638 10.18%

image

sopel39 and others added 7 commits April 13, 2023 09:58
Cherry-pick of trinodb/trino@0a70468

co-authored-by: Karol Sobczak <karol.sobczak@karolsobczak.com>
Cherry-pick of trinodb/trino@301ff47

Co-authored-by: skrzypo987<krzysztof.skrzypczynski@starburstdata.com>
If the number of combinations of all dictionaries in a page is below certain number,
we can store the results in a small array and reuse found groups

Cherry-pick of trinodb/trino@ffd1ee8

Co-authored-by: skrzypo987<krzysztof.skrzypczynski@starburstdata.com>
For simplicity and tiny performance gain.

Cherry-pick of trinodb/trino@7ec3bd0

Co-authored-by: skrzypo987 <krzysztof.skrzypczynski@starburstdata.com>
Cherry-pick of trinodb/trino@7ee53ea

Co-authored-by: skrzypo987 <krzysztof.skrzypczynski@starburstdata.com>
Cherry-pick of trinodb/trino@27e0c32

Co-authored-by: skrzypo987<krzysztof.skrzypczynski@starburstdata.com>
Previously the hash table capacity was checked every row to see whether a rehash
is needed. Now the input page is split into batches and it is assumed that every
row in batch will create a new group (which is rarely the case) and rehashing
is done in advance before processing.
This may slightly increase memory footprint for small number of groups, however
there is a tiny performance gain as the capacity is not checked every row.

Cherry-pick of trinodb/trino@88cd492

Co-authored-by: skrzypo987<krzysztof.skrzypczynski@starburstdata.com>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 18, 2023

CLA Not Signed

@fgwang7w fgwang7w requested a review from yingsu00 April 18, 2023 18:04
There's an off-by-one error in the check that
can cause a failure when the page is empty

Cherry-pick of trinodb/trino@08db4fb

Co-authored-by: Karol Sobczak <karol.sobczak@karolsobczak.com>
@fgwang7w fgwang7w force-pushed the optimizemultichannelgroupby branch from 3cb3d2a to cfcbaae Compare April 18, 2023 20:16
@yingsu00
Copy link
Contributor

@tdcmeehan Do you know how we solve the CLA problems?

@yingsu00 yingsu00 self-assigned this Apr 18, 2023
@fgwang7w
Copy link
Member Author

@tdcmeehan @yingsu00 gentle ping. we still have CLA compliance issues unsolved and need community's support to figure out how to make it passed. thanks

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.

4 participants