Skip to content
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

[Ray data optimization] Make min num chunks to trigger combine configurable #36

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion python/ray/data/_internal/batcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import logging
import os

from typing import Optional

from ray.data._internal.arrow_block import ArrowBlockAccessor
Expand All @@ -11,7 +14,8 @@
# See https://github.com/ray-project/ray/issues/31108 for more details.
# TODO(jjyao): remove this once
# https://github.com/apache/arrow/issues/35126 is resolved.
MIN_NUM_CHUNKS_TO_TRIGGER_COMBINE_CHUNKS = 2
# Make this configurable to void unnecessary combine chunks
MIN_NUM_CHUNKS_TO_TRIGGER_COMBINE_CHUNKS = int(os.getenv('RAY_DATA_MIN_NUM_CHUNKS_TO_TRIGGER_COMBINE_CHUNKS', 2))

# Delay compaction until the shuffle buffer has reached this ratio over the min
# shuffle buffer size. Setting this to 1 minimizes memory usage, at the cost of
Expand All @@ -20,6 +24,8 @@
SHUFFLE_BUFFER_COMPACTION_RATIO = 1.5


logger = logging.getLogger(__name__)

class BatcherInterface:
def add(self, block: Block):
"""Add a block to the block buffer.
Expand Down Expand Up @@ -142,6 +148,7 @@ def next_batch(self) -> Block:
and block.column(0).num_chunks
>= MIN_NUM_CHUNKS_TO_TRIGGER_COMBINE_CHUNKS
):
logger.warning(f"Detected combine_chunks in Batcher. Number of chunks: {block.column(0).num_chunks}, threshold: {MIN_NUM_CHUNKS_TO_TRIGGER_COMBINE_CHUNKS}")
accessor = BlockAccessor.for_block(
transform_pyarrow.combine_chunks(block)
)
Expand Down Expand Up @@ -313,6 +320,7 @@ def next_batch(self) -> Block:
and self._shuffle_buffer.column(0).num_chunks
>= MIN_NUM_CHUNKS_TO_TRIGGER_COMBINE_CHUNKS
):
logger.warning(f"Detected combine_chunks in ShuffleBatcher. Number of chunks: {block.column(0).num_chunks}, threshold: {MIN_NUM_CHUNKS_TO_TRIGGER_COMBINE_CHUNKS}")
self._shuffle_buffer = transform_pyarrow.combine_chunks(
self._shuffle_buffer
)
Expand Down