Repository navigation
[Data] Switched default shuffle strategy from sort-based to hash-based - #55510
Conversation
There was a problem hiding this comment.
Code Review
This pull request changes the default shuffle strategy in Ray Data from a sort-based approach to a hash-based one. This is a significant change to the default behavior that could have wide-ranging performance implications. While reviewing this change, I identified a critical bug that would cause a crash if a user tried to configure the shuffle strategy using the RAY_DATA_DEFAULT_SHUFFLE_STRATEGY environment variable. I've provided a fix for this issue in my review comments.
0e439c5 to
4473775
Compare
| if num_partitions is not None and num_partitions <= 0: | ||
| if num_partitions is None: | ||
| # TODO replace w/ size-based estimate | ||
| num_partitions = self._logical_plan.dag.estimated_num_outputs() |
There was a problem hiding this comment.
So this is a heuristic of the number of blocks outputted by this groupby step?
A couple of questions/concerns
- I'm a little worried this might result in extreme partition values (too small or too large, especially if a repartition precedes this operation)
- It seems
estimated_num_outputs()can returnNoneif_num_outputsis not set. What happens in this case?
| # - 5% of total available CPUs but | ||
| # - No more than 4 CPUs per aggregator | ||
| # | ||
| return min(4.0, total_available_cluster_resources.cpu * 0.05 / num_aggregators) |
There was a problem hiding this comment.
Just curious how we arrived at these defaults. Is there a simulation?
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
dae14de to
b197f5f
Compare
80765dd to
3619ede
Compare
Signed-off-by: Alexey Kudinkin <[email protected]>
…to `ray.cluster_resources()` when no cluster-configuration is available Signed-off-by: Alexey Kudinkin <[email protected]>
… by # of CPUs Signed-off-by: Alexey Kudinkin <[email protected]>
…ior stage is known Signed-off-by: Alexey Kudinkin <[email protected]>
Updated fixtures Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
ray-project#55510) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests. Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Alexey Kudinkin <[email protected]> Signed-off-by: zac <[email protected]>
#55510) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests. Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle. ## Related issue number <!-- For example: "Closes #1234" --> ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Alexey Kudinkin <[email protected]> Signed-off-by: elliot-barn <[email protected]>
ray-project#55510) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests. Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Alexey Kudinkin <[email protected]> Signed-off-by: Marco Stephan <[email protected]>
#55510) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests. Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle. ## Related issue number <!-- For example: "Closes #1234" --> ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Alexey Kudinkin <[email protected]> Signed-off-by: elliot-barn <[email protected]>
ray-project#55510) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests. Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Alexey Kudinkin <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
ray-project#55510) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests. Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Alexey Kudinkin <[email protected]>
ray-project#55510) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests. Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle. ## Related issue number <!-- For example: "Closes #1234" --> ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Alexey Kudinkin <[email protected]> Signed-off-by: Future-Outlier <[email protected]>
…ptions (#66604) ## Why are these changes needed? This PR corrects Ray Data source text that disagrees with the renamed docs headings or with the code it describes. It touches comments and docstrings only. ### Link text that repeats renamed headings The Ray Data style-pass stack renamed several headings to sentence case and imperative form. Three docstrings in `python/ray/data/` carry explicit `:ref:` titles that repeat the old heading text. This PR updates them to match: - `read_api.py`, `read_sql`: "Reading from SQL Databases" → "Read SQL databases" - `read_api.py`, `from_huggingface`: "Loading Hugging Face datasets" → "Load Hugging Face datasets" - `dataset.py`, `repartition`: "Advanced: Performance Tips and Tuning" → "Advanced: Performance tips and tuning", and "Changing the number of output files" → "Change the number of output files" - `dataset.py`, `random_shuffle`: "Optimizing shuffles" → "Optimize shuffles", and lowercases the start of an inline link that sits mid-sentence The labels don't change, so every reference resolves before and after this PR. The only effect is that the rendered link text matches the target heading. ### Source text that contradicts the code - `context.py`, `max_hash_shuffle_aggregators`: the comment said the default is twice the cluster CPU count. The code in `hash_shuffle.py` uses `min(max(1, ceil(cluster CPUs)), max_hash_shuffle_aggregators or DEFAULT_MAX_HASH_SHUFFLE_AGGREGATORS)`, and has never doubled since #55510 added the comment and the code together. The comment now says the CPU count, at least 1. - `execution_options.py`, `ExecutionOptions.verbose_progress`: #43360 made the option on by default and added "On by default.", but left the older sentence that described the off state as the default. That sentence now describes the off state explicitly. This matches `RAY_DATA_VERBOSE_PROGRESS` defaulting to `"1"`. After this change the API reference agrees with the `execution-configurations.md` and `joining-data.md` pages. The link-text edits used to sit in #66419, #66420, and #66423. They moved here so the docs-only PRs in the stack need only docs review. ## Related issue number None. Follow-up to the stack starting at #66418. ## Checks - Not a duplicate. No other open PR touches these docstrings or comments. - `pre-commit` passed on all four files, including ruff, black, pydoclint, and the Ray docstyle check. - The diff changes comment and docstring text only. No code, defaults, or labels change. - AI assistance (Claude Code) was used to prepare this PR. I reviewed every changed line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…ptions (ray-project#66604) ## Why are these changes needed? This PR corrects Ray Data source text that disagrees with the renamed docs headings or with the code it describes. It touches comments and docstrings only. ### Link text that repeats renamed headings The Ray Data style-pass stack renamed several headings to sentence case and imperative form. Three docstrings in `python/ray/data/` carry explicit `:ref:` titles that repeat the old heading text. This PR updates them to match: - `read_api.py`, `read_sql`: "Reading from SQL Databases" → "Read SQL databases" - `read_api.py`, `from_huggingface`: "Loading Hugging Face datasets" → "Load Hugging Face datasets" - `dataset.py`, `repartition`: "Advanced: Performance Tips and Tuning" → "Advanced: Performance tips and tuning", and "Changing the number of output files" → "Change the number of output files" - `dataset.py`, `random_shuffle`: "Optimizing shuffles" → "Optimize shuffles", and lowercases the start of an inline link that sits mid-sentence The labels don't change, so every reference resolves before and after this PR. The only effect is that the rendered link text matches the target heading. ### Source text that contradicts the code - `context.py`, `max_hash_shuffle_aggregators`: the comment said the default is twice the cluster CPU count. The code in `hash_shuffle.py` uses `min(max(1, ceil(cluster CPUs)), max_hash_shuffle_aggregators or DEFAULT_MAX_HASH_SHUFFLE_AGGREGATORS)`, and has never doubled since ray-project#55510 added the comment and the code together. The comment now says the CPU count, at least 1. - `execution_options.py`, `ExecutionOptions.verbose_progress`: ray-project#43360 made the option on by default and added "On by default.", but left the older sentence that described the off state as the default. That sentence now describes the off state explicitly. This matches `RAY_DATA_VERBOSE_PROGRESS` defaulting to `"1"`. After this change the API reference agrees with the `execution-configurations.md` and `joining-data.md` pages. The link-text edits used to sit in ray-project#66419, ray-project#66420, and ray-project#66423. They moved here so the docs-only PRs in the stack need only docs review. ## Related issue number None. Follow-up to the stack starting at ray-project#66418. ## Checks - Not a duplicate. No other open PR touches these docstrings or comments. - `pre-commit` passed on all four files, including ruff, black, pydoclint, and the Ray docstyle check. - The diff changes comment and docstring text only. No code, defaults, or labels change. - AI assistance (Claude Code) was used to prepare this PR. I reviewed every changed line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Why are these changes needed?
Hash-based shuffle has been around for some time now bringing clear performance advantages in our internal benchmarks and tests.
Therefore we're switching default shuffle-strategy from existing (legacy) range-sort based one to a hash-shuffle.
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.