Skip to content

Conversation

@iamjustinhsu
Copy link
Contributor

@iamjustinhsu iamjustinhsu commented Sep 22, 2025

Why are these changes needed?

Currently, users who specify max_concurrency>1 don't actually experience multi-threaded concurrency in their actors. This PR addresses that by allowing users to override actor pool max_concurrency behavior. Changes I made

  • BY DEFAULT, the behavior before and after this PR is preserved
  • IF users want to respect max_concurrency, they can set enable_true_multi_threading=True in their ActorComputeStrategy

Related issue number

#55354

Checks

Tests:

NONE YET

  • 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: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
@iamjustinhsu iamjustinhsu added the go add ONLY when ready to merge, run all tests label Sep 23, 2025
@github-actions
Copy link

github-actions bot commented Oct 8, 2025

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 Oct 8, 2025
@iamjustinhsu iamjustinhsu removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 8, 2025
@github-actions
Copy link

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 Oct 22, 2025
@iamjustinhsu iamjustinhsu removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 22, 2025
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

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 Nov 6, 2025
@iamjustinhsu iamjustinhsu removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Nov 6, 2025
@github-actions
Copy link

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 Nov 28, 2025
@iamjustinhsu iamjustinhsu removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Dec 1, 2025
@iamjustinhsu iamjustinhsu changed the title [wip][data] remove concurrency lock [data] remove concurrency lock Dec 2, 2025
@iamjustinhsu iamjustinhsu marked this pull request as ready for review December 2, 2025 18:44
@iamjustinhsu iamjustinhsu requested a review from a team as a code owner December 2, 2025 18:44
@ray-gardener ray-gardener bot added the data Ray Data-related issues label Dec 2, 2025
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
max_size: Optional[int] = None,
initial_size: Optional[int] = None,
max_tasks_in_flight_per_actor: Optional[int] = None,
single_threaded: bool = True,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
single_threaded: bool = True,
enable_true_multi_threading: bool = False,

Copy link
Contributor

Choose a reason for hiding this comment

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

Also add ample commentary to explain the difference

Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
f"initial_size={self.initial_size}, "
f"max_tasks_in_flight_per_actor={self.max_tasks_in_flight_per_actor})"
f"num_workers={self.num_workers}, "
f"enable_true_multi_threading={self.enable_true_multi_threading}, "
Copy link

Choose a reason for hiding this comment

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

Bug: Malformed repr string with misplaced closing parenthesis

The __repr__ method has a closing parenthesis ) at the end of the max_tasks_in_flight_per_actor line, but continues with more fields (num_workers, enable_true_multi_threading, ready_to_total_workers_ratio) followed by another ). This produces malformed output like ActorPoolStrategy(...)num_workers=..., enable_true_multi_threading=..., ...) where fields after the first ) appear outside the constructor notation.

Fix in Cursor Fix in Web

Comment on lines 267 to 271
enable_true_multi_threading: bool = (
compute.enable_true_multi_threading
if isinstance(compute, ActorPoolStrategy)
else True
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just do it inside _get_udf to avoid duplication

Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Comment on lines 331 to 336
if (
not is_async_udf
and isinstance(compute, ActorPoolStrategy)
and not compute.enable_true_multi_threading
):
udf = make_callable_class_single_threaded(udf)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment to explain the behavior here

Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
Signed-off-by: Alexey Kudinkin <alexey.kudinkin@gmail.com>
@alexeykudinkin alexeykudinkin enabled auto-merge (squash) December 4, 2025 18:17
@github-actions github-actions bot disabled auto-merge December 4, 2025 18:17
Signed-off-by: iamjustinhsu <jhsu@anyscale.com>
@alexeykudinkin alexeykudinkin merged commit edff0f6 into ray-project:master Dec 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants