Skip to content

Commit 4fe4f57

Browse files
feat: Add unbounded memory pool (#1386)
## Which issue does this PR close? ## Rationale for this change DataFusion has an unbounded memory pool. I found it useful for experimental purpose. ## What changes are included in this PR? Added an option for unbounded memory pool. ## How are these changes tested? existing tests
1 parent f099e6e commit 4fe4f57

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

common/src/main/scala/org/apache/comet/CometConf.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ object CometConf extends ShimCometConf {
504504
.doc(
505505
"The type of memory pool to be used for Comet native execution. " +
506506
"Available memory pool types are 'greedy', 'fair_spill', 'greedy_task_shared', " +
507-
"'fair_spill_task_shared', 'greedy_global' and 'fair_spill_global'. For off-heap " +
508-
"types are 'unified' and `fair_unified`.")
507+
"'fair_spill_task_shared', 'greedy_global', 'fair_spill_global', and `unbounded`. " +
508+
"For off-heap types are 'unified' and `fair_unified`.")
509509
.stringConf
510510
.createWithDefault("greedy_task_shared")
511511

docs/source/user-guide/configs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Comet provides the following configuration settings.
4848
| spark.comet.exec.hashJoin.enabled | Whether to enable hashJoin by default. | true |
4949
| spark.comet.exec.initCap.enabled | Whether to enable initCap by default. | false |
5050
| spark.comet.exec.localLimit.enabled | Whether to enable localLimit by default. | true |
51-
| 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-heap types are 'unified' and `fair_unified`. | greedy_task_shared |
51+
| 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', 'fair_spill_global', and `unbounded`. For off-heap types are 'unified' and `fair_unified`. | greedy_task_shared |
5252
| spark.comet.exec.project.enabled | Whether to enable project by default. | true |
5353
| spark.comet.exec.replaceSortMergeJoin | Experimental feature to force Spark to replace SortMergeJoin with ShuffledHashJoin for improved performance. This feature is not stable yet. For more information, refer to the Comet Tuning Guide (https://datafusion.apache.org/comet/user-guide/tuning.html). | false |
5454
| spark.comet.exec.shuffle.compression.codec | The codec of Comet native shuffle used to compress shuffle data. lz4, zstd, and snappy are supported. Compression can be disabled by setting spark.shuffle.compress=false. | lz4 |

native/core/src/execution/jni_api.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use datafusion::{
2626
prelude::{SessionConfig, SessionContext},
2727
};
2828
use datafusion_execution::memory_pool::{
29-
FairSpillPool, GreedyMemoryPool, MemoryPool, TrackConsumersPool,
29+
FairSpillPool, GreedyMemoryPool, MemoryPool, TrackConsumersPool, UnboundedMemoryPool,
3030
};
3131
use futures::poll;
3232
use jni::{
@@ -118,6 +118,7 @@ enum MemoryPoolType {
118118
FairSpillTaskShared,
119119
GreedyGlobal,
120120
FairSpillGlobal,
121+
Unbounded,
121122
}
122123

123124
struct MemoryPoolConfig {
@@ -319,6 +320,7 @@ fn parse_memory_pool_config(
319320
"greedy_global" => MemoryPoolConfig::new(MemoryPoolType::GreedyGlobal, pool_size),
320321
"fair_spill" => MemoryPoolConfig::new(MemoryPoolType::FairSpill, pool_size_per_task),
321322
"greedy" => MemoryPoolConfig::new(MemoryPoolType::Greedy, pool_size_per_task),
323+
"unbounded" => MemoryPoolConfig::new(MemoryPoolType::Unbounded, 0),
322324
_ => {
323325
return Err(CometError::Config(format!(
324326
"Unsupported memory pool type: {}",
@@ -397,6 +399,7 @@ fn create_memory_pool(
397399
per_task_memory_pool.num_plans += 1;
398400
Arc::clone(&per_task_memory_pool.memory_pool)
399401
}
402+
MemoryPoolType::Unbounded => Arc::new(UnboundedMemoryPool::default()),
400403
}
401404
}
402405

0 commit comments

Comments
 (0)