-
Notifications
You must be signed in to change notification settings - Fork 182
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
feat: Add fair unified memory pool #1369
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1369 +/- ##
=============================================
- Coverage 56.12% 39.06% -17.06%
- Complexity 976 2071 +1095
=============================================
Files 119 263 +144
Lines 11743 60746 +49003
Branches 2251 12909 +10658
=============================================
+ Hits 6591 23733 +17142
- Misses 4012 32530 +28518
- Partials 1140 4483 +3343 ☔ View full report in Codecov by Sentry. |
docs/source/user-guide/configs.md
Outdated
@@ -48,7 +48,7 @@ Comet provides the following configuration settings. | |||
| spark.comet.exec.hashJoin.enabled | Whether to enable hashJoin by default. | true | | |||
| spark.comet.exec.initCap.enabled | Whether to enable initCap by default. | false | | |||
| spark.comet.exec.localLimit.enabled | Whether to enable localLimit by default. | true | | |||
| spark.comet.exec.memoryPool | The type of memory pool to be used for Comet native execution. Available memory pool types are 'greedy', 'fair_spill', 'greedy_task_shared', 'fair_spill_task_shared', 'greedy_global' and 'fair_spill_global', By default, this config is 'greedy_task_shared'. | greedy_task_shared | | |||
| spark.comet.exec.memoryPool | The type of memory pool to be used for Comet native execution. Available memory pool types are 'greedy', 'fair_spill', 'greedy_task_shared', 'fair_spill_task_shared', 'greedy_global' and 'fair_spill_global'. For off-eap types are 'unified' and `fair_unified`. | greedy_task_shared | |
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 default is fair_unified
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.
We tend to omit what the default value is. When default value is changed, the option description is often forgotten to be updated because there is no checking for the description. So we deleted default value explanations in the past
Co-authored-by: Zhen Wang <[email protected]>
Co-authored-by: Zhen Wang <[email protected]>
impl MemoryPool for CometFairMemoryPool { | ||
fn register(&self, _: &MemoryConsumer) { | ||
let mut state = self.state.lock(); | ||
state.num = state.num.checked_add(1).unwrap(); |
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.
this unwraps can be super confusing if they happen
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.
This won't happen in reality, num
is usize
. I wouldn't worry about it.
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.
changed to expect()
with a message
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 @kazuyukitanimura nice job
unwraps probably could be wrapped into user friendly messages or its gonna super confusing to unwrap
panic when it is supposed to be a memory or memory manager issue.
Co-authored-by: Oleks V <[email protected]>
Co-authored-by: Oleks V <[email protected]>
state.num = state.num.checked_sub(1).unwrap(); | ||
} | ||
|
||
fn grow(&self, reservation: &MemoryReservation, additional: usize) { |
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.
This method implementation seems to be different from memory_pool
, but I'm not sure which one is reasonable.
@andygrove I would like to make sure to include this for the 0.6.0 release |
I added this PR to #1361 |
Thanks @andygrove for trying. You may have to increase the memory because the fair memory pool limits memory usage earlier in order to leave the the rest for other threads. |
Went ahead and kept the default pool choice @andygrove |
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 @kazuyukitanimura
Merged, thanks @andygrove |
## Which issue does this PR close? ## Rationale for this change Current Comet unified memory pool is a greedy pool. One thread (consumer) can take a large amount of memory that causes OOM for other threads, especially for aggregation. ## What changes are included in this PR? Added a fair version of unified memory pool similar to DataFusion `FairSpilPool` that caps the memory usage at `pool_size/num` The fair unified memory pool is the default for off-heap mode with this PR ## How are these changes tested? Exisiting tests
Which issue does this PR close?
Rationale for this change
Current Comet unified memory pool is a greedy pool. One thread (consumer) can take a large amount of memory that causes OOM for other threads, especially for aggregation.
What changes are included in this PR?
Added a fair version of unified memory pool similar to DataFusion
FairSpilPool
that caps the memory usage atpool_size/num
The fair unified memory pool is the default for off-heap mode with this PR
How are these changes tested?
Exisiting tests