Skip to content

feat: add fair_unified_task_shared memory pool to fix 2x memory allocation [experimental]#3924

Draft
andygrove wants to merge 1 commit intoapache:mainfrom
andygrove:task-shared-unified-pool
Draft

feat: add fair_unified_task_shared memory pool to fix 2x memory allocation [experimental]#3924
andygrove wants to merge 1 commit intoapache:mainfrom
andygrove:task-shared-unified-pool

Conversation

@andygrove
Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #3921

Rationale for this change

When Comet executes a shuffle, it creates two separate native plans (the child plan and the shuffle writer plan) that run concurrently in a pipelined fashion. Previously, each plan got its own memory pool at the full per-task limit, effectively allowing 2x the intended memory to be consumed.

The new fair_unified_task_shared pool type shares a single CometFairMemoryPool across all native plans within the same Spark task. This ensures the total memory stays within the per-task limit while dynamically distributing memory among operators based on how many register as memory consumers (e.g. if the child plan is a simple scan+filter, the shuffle writer gets 100% of the pool).

This is now the default for off-heap mode.

What changes are included in this PR?

How are these changes tested?

…ation

When Comet executes a shuffle, it creates two separate native plans (the
child plan and the shuffle writer plan) that run concurrently in a
pipelined fashion. Previously, each plan got its own memory pool at the
full per-task limit, effectively allowing 2x the intended memory to be
consumed.

The new `fair_unified_task_shared` pool type shares a single
CometFairMemoryPool across all native plans within the same Spark task.
This ensures the total memory stays within the per-task limit while
dynamically distributing memory among operators based on how many
register as memory consumers (e.g. if the child plan is a simple
scan+filter, the shuffle writer gets 100% of the pool).

This is now the default for off-heap mode.

Closes apache#3921

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comet allocates 2x available memory in memory pools for executePlan

1 participant