-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Reset MultiChannelGroupByHash.currentPageBuilder to exact position count #12512
Reset MultiChannelGroupByHash.currentPageBuilder to exact position count #12512
Conversation
fccc31f
to
3326feb
Compare
|
3326feb
to
fbdf135
Compare
if we decide to go ahead with this change, |
core/trino-spi/src/main/java/io/trino/spi/block/VariableWidthBlockBuilder.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/BlockBuilder.java
Outdated
Show resolved
Hide resolved
@@ -98,6 +98,19 @@ public void reset() | |||
} | |||
} | |||
|
|||
public void resetExact() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add reset(int expectedEntries)
method instead.
Exact is ambiguous. Exact what? positions? size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
90%* of method names are ambiguous (see no further than newBlockBuilderLike
).
I think keeping the method without expectedEntries
param is better as we don't need the extended functionality of resetting PageBuilder
to any position count.
- made up stat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Łukasz. The name is not that bad, and it will only be invoked with the same argument every time. Some simple javadoc might be added though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely needs a javadoc
Alternatively, how about a PageBuilder newPageBuilderLike(int expectedEntries)
method instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid the Javadoc but also avoid exposing unnecessary functionality I added private
private void reset(int expectedEntries)
and public resetExact with an extremely straightforward implementation that does not need documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset(int expectedEntries)
may correspond to the PageBuilder
constructor but it's not needed, why add it to the public API?
How about instead of inlining resetExact
we change the name to be less ambiguous? The approach of inlining method calls because we don't like the method name is not good long term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you can inline it TBH due to page builder status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping 9e984ab#r950126334
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sopel39 see https://github.com/trinodb/trino/pull/12512/files#r950167250
to sum up. we don't need reset(int expectedEntries)
public API, we need resetExact
. If the name is misleading please propose a better name but I stand by the fact that resetExact
captures the semantics we need and reset(int expectedEntries)
adds complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in order to move forward with the PR I dropped the resetExact
and made void reset(int expectedEntries)
public.
core/trino-main/src/main/java/io/trino/operator/MultiChannelGroupByHash.java
Outdated
Show resolved
Hide resolved
fbdf135
to
a2e608a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebased on the master + renamed newBlockBuilderLike param
core/trino-main/src/main/java/io/trino/operator/MultiChannelGroupByHash.java
Outdated
Show resolved
Hide resolved
@@ -98,6 +98,19 @@ public void reset() | |||
} | |||
} | |||
|
|||
public void resetExact() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
90%* of method names are ambiguous (see no further than newBlockBuilderLike
).
I think keeping the method without expectedEntries
param is better as we don't need the extended functionality of resetting PageBuilder
to any position count.
- made up stat
this change adds new method to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
Since the pages considered her are temporary (not the output ones), consider making them fixed size from the beginning (let's say of size 1024). That way the value lookup consists of a bit shift and a single memory lookup instead of two. That is just me thinking out loud, you can consider this out of scope.
@@ -98,6 +98,19 @@ public void reset() | |||
} | |||
} | |||
|
|||
public void resetExact() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Łukasz. The name is not that bad, and it will only be invoked with the same argument every time. Some simple javadoc might be added though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % comment.
Also, PTAL if GeneratedPageProjection#project
can benefit from similar exact sizing
@@ -98,6 +98,19 @@ public void reset() | |||
} | |||
} | |||
|
|||
public void resetExact() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely needs a javadoc
Alternatively, how about a PageBuilder newPageBuilderLike(int expectedEntries)
method instead ?
Not an expert in projection but it looks like this could indeed benefit from the exact sizing. I can do this as I follow up on this PR. |
a2e608a
to
9b54b1a
Compare
@skrzypo987 I think this could have negative consequences if the number of groups is small |
9b54b1a
to
2706561
Compare
@lukasz-stec PTAL at test failures |
@raunaqmorarka |
I think we need to keep the existing API around as well to keep it backward compatible. Maybe mark it Deprecated. |
The existing API is still there but now it's implemented as a default interface method. |
If it's not going to require changes to any existing usage (i.e. it's not really backward incompatible change), then we can probably just add the changes to the exceptions list with a comment to get past this. |
be20719
to
9e984ab
Compare
rebased on the master + added |
55566f2
to
18e1c53
Compare
core/trino-spi/src/main/java/io/trino/spi/block/MapBlockBuilder.java
Outdated
Show resolved
Hide resolved
@electrum landed API verifier, please rebase and make sure tests pass |
18e1c53
to
0699a68
Compare
rebased and added an exception to the revapi config. |
Since MultiChannelGroupByHash knows exactly how many positions currentPageBuilder can eventually contain, there is no need to increase the size with calculateBlockResetSize, wasting memory in the process.
0699a68
to
4a971e9
Compare
Description
Since
MultiChannelGroupByHash
knows exactly how manypositions
currentPageBuilder
can eventually contain,there is no need to increase the size with
calculateBlockResetSize
, wasting memory in the process.This fixes #12484
It's based on #12336. Only last commit matters here.
tpch/tpcds benchmark
There is a 1-2 % improvement in peak memory consumption.
reset-exeact-orc-part-sf1000.pdf
improvement
core query engine, spi
BlockBuilder
Lower hash aggregation memory consumption
Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( ) Release notes entries required with the following suggested text: