Skip to content

[Data] Optimize triple loop in default_autoscaling_coordinator.py - #61487

Open
weimingdiit wants to merge 3 commits into
ray-project:masterfrom
weimingdiit:data/fix-optimize-triple-loop
Open

weimingdiit wants to merge 3 commits into
ray-project:masterfrom
weimingdiit:data/fix-optimize-triple-loop

Conversation

@weimingdiit

Copy link
Copy Markdown
Contributor

Description

This issue addresses a resource-allocation performance bottleneck in Ray Data autoscaling.

Previously, the coordinator used a triple nested loop when reallocating resources (requesters × requested bundles × cluster nodes). That made allocation cost grow quickly as concurrency increased, causing unnecessary CPU overhead and slower autoscaler reaction times. It was especially inefficient for repeated identical bundles, which were rescanned across nodes from the beginning each time.

Related issues

#61485

@weimingdiit
weimingdiit marked this pull request as ready for review March 4, 2026 12:06
@weimingdiit
weimingdiit requested a review from a team as a code owner March 4, 2026 12:06

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively optimizes the resource reallocation logic in default_autoscaling_coordinator.py by replacing an inefficient triple nested loop. The new implementation cleverly uses caching for bundle search positions and tracks impossible-to-allocate bundles, which should significantly reduce CPU overhead and improve autoscaler responsiveness, especially in scenarios with many identical resource requests. The logic appears sound and addresses the performance bottleneck described. I have reviewed the changes and found no issues.

@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Mar 4, 2026

@slfan1989 slfan1989 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weimingdiit Thanks for the contribution!

Looks good to me with one minor comment.

Signed-off-by: weimingdiit <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

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.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Mar 19, 2026
@weimingdiit

weimingdiit commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi, @bveeramani @abrarsheikh when you have a chance, could you please take a look at this PR?

@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Mar 20, 2026
@weimingdiit

weimingdiit commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@iamjustinhsu @goutamvenkat-anyscale Hi, could you please take a look at this PR?

This branch has not been deployed

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

Labels

community-contribution Contributed by the community data Ray Data-related issues unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants