-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Aggressively prune query info after completion #23257
Aggressively prune query info after completion #23257
Conversation
9165744
to
6cfe291
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.
Can you check (and maybe add/link me to a test that asserts) that the queryCompletedEvent is fired before the query info pruning is done ?
6cfe291
to
0ebbd10
Compare
presto-tests/src/test/java/com/facebook/presto/tests/TestQueryManager.java
Show resolved
Hide resolved
0ebbd10
to
20af877
Compare
20af877
to
735877a
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.
LGTM, just one nit.
presto-main/src/main/java/com/facebook/presto/execution/QueryStateMachine.java
Outdated
Show resolved
Hide resolved
new RuntimeStats()), | ||
Optional.empty(), | ||
Optional.empty(), | ||
ImmutableMap.of(), |
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.
Tangential and non-blocking, but I'd like to get in the habit of using Collections.emptyMap instead of ImmutableList.of to reduce our dependence on and vulnerability to third party libraries. ImmutableMap.of hasn't been needed for years now.
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.
If this is the case, then we should update the contributing guide to state that:
Line 199 in 9a3c695
* Prefer Immutable collections in Guava when possible. For example, instead of using |
Optional.empty(), | ||
Optional.empty(), | ||
ImmutableMap.of(), | ||
ImmutableSet.of(), |
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.
Collections.emptySet
ImmutableSet.of(), | ||
StatsAndCosts.empty(), | ||
ImmutableList.of(), | ||
ImmutableList.of(), |
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.
Collections.emptyList
Optional.empty(), | ||
null, | ||
EXCEEDED_GLOBAL_MEMORY_LIMIT.toErrorCode(), | ||
ImmutableList.of( |
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.
here you can use Arrays.asList
It's just a test so immutability doesn't help
presto-main/src/main/java/com/facebook/presto/execution/QueryStateMachine.java
Outdated
Show resolved
Hide resolved
735877a
to
394ba9f
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.
Thanks for the fix.
presto-main/src/main/java/com/facebook/presto/execution/QueryTracker.java
Outdated
Show resolved
Hide resolved
394ba9f
to
fab2478
Compare
d597d84
to
e3d09ad
Compare
presto-main/src/main/java/com/facebook/presto/dispatcher/FailedDispatchQuery.java
Outdated
Show resolved
Hide resolved
1927346
to
e2b9965
Compare
Previously, we only pruned information from old queries after the expiration queue filled. With more the addition of histograms query statistics can take two orders of magnitude more memory than previous statistics. Without pruning statistics we will much more quickly hit memory limits of the JVM. This change aggressively prunes query plan metadata before query expiry. This is mostly limited to query plan statistics.
e2b9965
to
8d27c93
Compare
Description
This change aggressively prunes query plan metadata before query expiry. It is mostly limited to query plan statistics.
With this change and with histograms enabled in #22365, this cuts the coordinator heap utilization by anywhere between 50% and 75% after running a portion of the TPC-DS benchmark (3-4GiB -> 600-800MiB)
Motivation and Context
Previously, we only pruned information from old queries after the expiration queue filled. With the addition of histograms query statistics can take two orders of magnitude more memory than previous statistics. Without pruning statistics we will much more quickly hit memory limits of the JVM.
Specifically, these are the areas where we try to clear references to save memory:
planNodeStatsMap
andplanCostMapMap
inputs
andplanStatsAndCosts
finalQueryInfo
'splanStatsAndCosts
and from the entireStageInfo
graph.Fixes #23254
Impact
Test Plan
Contributor checklist
Release Notes