Skip to content

Apply memory backpressure to the shuffle - #23834

Draft
madsbk wants to merge 1 commit into
NVIDIA:pull-request/23833from
madsbk:apply-memory-backpressure-to-the-shuffle
Draft

Apply memory backpressure to the shuffle#23834
madsbk wants to merge 1 commit into
NVIDIA:pull-request/23833from
madsbk:apply-memory-backpressure-to-the-shuffle

Conversation

@madsbk

@madsbk madsbk commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Depend on #23833.

The shuffle now takes its device memory from reserve_memory() on both sides, the four ShuffleManager.Inserter methods going in and extract_chunk coming out, so a request that cannot be satisfied queues alongside the other actors' and is served by priority. Before this both let the C++ side reserve and spill internally. cudf-polars already reserves this way for scans in actor_graph/io.py.

Breaking change

The insert methods and extract_chunk are coroutines now, and LocalRepartitioner._iter_chunks is an async generator. That updates twenty-one call sites across groupby.py, over.py, sort.py, shuffle.py and the shuffler tests.

Notes

Reserving inside the insert methods rather than at the call sites keeps the accounting in one place. That matters for insert_hash_keys and insert_index, whose Python-side reorder allocates a full table copy that nothing reserved before. They reserve partition_and_pack_cost(), which covers a reorder plus a pack, consume the reorder's share once it lands, and hand the remainder to split_and_pack().

_iter_chunks reserves per piece, so the TODO there about batching pieces up to target_partition_size would cut the reservation traffic as well as the unpack overhead.

@madsbk madsbk self-assigned this Aug 26, 2026
@madsbk madsbk added improvement Improvement / enhancement to an existing function breaking Breaking change labels Aug 26, 2026
@copy-pr-bot

copy-pr-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Aug 26, 2026
@madsbk
madsbk changed the base branch from main to pull-request/23833 August 26, 2026 12:50
@madsbk

madsbk commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change cudf-polars Issues specific to cudf-polars improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant