Improve chunk sampling in dynamic actors - #23051
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR switches streaming chunk buffering and sampling to ChangesChunkStore Sampling and Replay Refactor
Join fallback for expression keys
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/cudf_polars/cudf_polars/streaming/actor_graph/collectives/sort.py`:
- Line 254: The partition count calculation in sort.py underestimates the number
of dynamic sort partitions because `global_size // target_partition_size` floors
non-exact multiples. Update the logic in the partition-sizing code that assigns
`num_partitions` to use ceiling division instead, so values like `1.9 *
target_partition_size` produce 2 partitions rather than 1. Keep the existing
`max(1, ...)` guard, but change the division behavior in the `num_partitions`
expression to preserve the target-size budget.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 552a10c8-caeb-423d-b16e-eb51ac442b4f
📒 Files selected for processing (4)
python/cudf_polars/cudf_polars/streaming/actor_graph/collectives/sort.pypython/cudf_polars/cudf_polars/streaming/actor_graph/join.pypython/cudf_polars/cudf_polars/streaming/actor_graph/utils.pypython/cudf_polars/cudf_polars/utils/config.py
|
Nice! One potential real test failure to look at |
TomAugspurger
left a comment
There was a problem hiding this comment.
Looks like a nice cleanup.
Thanks for calling that out @Matt711 - Looks like this change may have moved the |
Thanks, if it ends up being #21641. I'm planning on refreshing my PR soon that closes it. And so you could xfail it. |
| ir, | ||
| rec, | ||
| msg="Multi-partition Join not supported for keys with expressions.", | ||
| ) |
There was a problem hiding this comment.
@Matt711 - It seems like the test_join_computed_expr_right_key failure was related to the fact that #21692 never landed, yet we have been failing to protect against computed keys in a shuffle join.
The test was previously "missing" the problem, because we were choosing a broadcast join.
The fix I added here is the "simplest" one. However, something like 21692 is definitely better.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/cudf_polars/cudf_polars/streaming/join.py`:
- Around line 212-222: The expression-key guard in join lowering is firing too
early in the streaming join path. Update the logic in the join lowering function
around the existing key check on ir.left_on and ir.right_on so it runs only
after output_count and dynamic_planning are known, and only falls back when a
hash shuffle is actually required. Keep single-partition cases that reconstruct
the node directly from being sent to _lower_ir_fallback, and preserve the
existing multi-partition/dynamic-planning fallback behavior for computed keys.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 59892d1e-bdec-4698-8bea-83fa6331caf7
📒 Files selected for processing (2)
python/cudf_polars/cudf_polars/streaming/join.pypython/cudf_polars/tests/streaming/test_join.py
|
/merge |
Description
join_actorandsort_actor. This contributes unnecessary memory pressure. When we sample a chunk, we only need to know the size and row count, which are both available on theTableChunk(regardless of its CPU/GPU residency). This PR updates the_sample_chunksutility to leverage the existingChunkStoreutility, and avoid manual un-spilling.join_actorandsort_actor. This PR updates these actors to use the same_sample_chunksutility.sample_chunk_countto limit the number of chunks we are willing to sample for dynamic planning purposes, even if the first 1-2 chunks are empty.This PR updates the meaning of(EDIT: After benchmarking, I decided to roll back this change - for now)sample_chunk_countso that we sample until the buffered byte size exceedstarget_partition_size * sample_chunk_count(or the channel is drained). This improves the quality of our sampling statistics.Together, these changes make dynamic sampling more stable and effective. In the case that we are dealing with skewed data, it also allows us to increase
sample_chunk_countto improve the plan without adding unnecessary memory pressure.Checklist