feat(executor): bound executor memory via --memory-pool-size#1624
Merged
andygrove merged 8 commits intoapache:mainfrom Apr 29, 2026
Merged
feat(executor): bound executor memory via --memory-pool-size#1624andygrove merged 8 commits intoapache:mainfrom
andygrove merged 8 commits intoapache:mainfrom
Conversation
Adds wrap_runtime_producer_with_memory_pool, which takes a RuntimeProducer and a total byte budget, and returns a new producer that installs a FairSpillPool of size total/concurrent_tasks on every produced RuntimeEnv. Also moves TryFrom<Config> impl above the test module in config.rs to fix a pre-existing clippy::items_after_test_module lint.
Wire wrap_runtime_producer_with_memory_pool into start_executor_process so that when --memory-pool-size is set, each task's RuntimeEnv receives a FairSpillPool sized to total / concurrent_tasks. Remove the now-unused #[allow(dead_code)] attribute and pub(crate) visibility from the helper.
Resolves rustdoc broken-intra-doc-link error in executor_process.rs. RuntimeEnv was not imported, so the bare [RuntimeEnv] link could not resolve. Use a fully qualified path link instead of adding an otherwise unused import.
milenkovicm
reviewed
Apr 29, 2026
| total, | ||
| concurrent_tasks, | ||
| )?; | ||
| let per_task = total / concurrent_tasks as u64; |
Contributor
There was a problem hiding this comment.
i wonder should we divide usable memory across tasks or use shared memory pool across all of them? is spark doing this ?
Contributor
There was a problem hiding this comment.
i guess this is consistent with spark executor, is it ?
Member
Author
There was a problem hiding this comment.
This is the approach that we use in Comet - each task gets its own fair pool and within a task, the operators share that pool. This keeps things predictable and stable.
We can certainly explore adding other config options in the future.
milenkovicm
approved these changes
Apr 29, 2026
Member
Author
|
Thanks for the review @milenkovicm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #1563
Rationale for this change
The executor today builds a
RuntimeEnvwith noMemoryPool, so DataFusion uses its unbounded default and spillable operators (sort, hash join, hash agg) grow until the host OOMs. There is no way to bound executor memory or trigger spilling. Thetuning-guide.mdalready flagged this as future work.What changes are included in this PR?
Adds an opt-in
--memory-pool-size <SIZE>flag (e.g.8GB,512MiB, plain bytes) on the executor binary. When set, every task receives an isolatedFairSpillPoolof sizetotal / concurrent_tasks. Wrapping is applied after the baseRuntimeProduceris resolved, so it composes with embedder-supplied producers (including the existing S3 helper) and preserves theirDiskManager,CacheManager, andObjectStoreRegistry. Hard error at startup if the per-task share would round to zero.Adds
bytesizeas a dep onballista-executorfor size parsing. No public API changes outside the executor crate.Are there any user-facing changes?
Yes. New optional CLI flag and a new section in
docs/source/user-guide/tuning-guide.md. Default behavior is unchanged when the flag is omitted.