Skip to content

[core] only let worker subscribe to owner death when actor level back pressure is enabled - #65136

Merged
rueian merged 3 commits into
ray-project:masterfrom
rueian:fix-actor-level-backpressure-subscription
Aug 4, 2026
Merged

rueian merged 3 commits into
ray-project:masterfrom
rueian:fix-actor-level-backpressure-subscription

Conversation

@rueian

@rueian rueian commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Previously, workers were always subscribing to GCS for owner death notification, but that was only needed for actor-level backpressure. This PR makes the subscription only when actor-level backpressure is enabled.

@rueian rueian added core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests labels Jul 30, 2026
@rueian
rueian marked this pull request as ready for review July 30, 2026 22:15
@rueian
rueian requested a review from a team as a code owner July 30, 2026 22:15
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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 refactors the subscription to owner-worker failures by moving it from RegisterToGcs into a dedicated SubscribeToOwnerWorkerFailures method, which is lazily invoked when creating an actor with actor-wide backpressure. The subscription is now safely guarded by std::call_once. Feedback was provided regarding a potential use-after-free vulnerability: capturing this directly in the asynchronous callback can lead to lifetime issues if the CoreWorker is destroyed. It is recommended to capture a std::weak_ptr<CoreWorker> instead and lock it inside the callback.

Comment thread src/ray/core_worker/core_worker.cc Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit b413529. Configure here.

Comment thread src/ray/core_worker/core_worker.cc Resolved
rueian added 2 commits July 30, 2026 15:22
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
@rueian
rueian merged commit 37d6115 into ray-project:master Aug 4, 2026
6 checks passed
sampan-s-nayak added a commit that referenced this pull request Aug 6, 2026
…r deaths for generator backpressure (#65195)

## Description

Follow-up to #65136: instead of the backpressured generator executor
subscribing to all worker failures and filtering client-side, this adds
support for keyed `SubscribeWorkerFailure(worker_id)` to the
pubsub/accessor layers and has the core worker subscribe only to the
owners of the backpressured generator tasks it is actually running.

---------

Signed-off-by: sampan <[email protected]>
Co-authored-by: sampan <[email protected]>
Co-authored-by: Rueian <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
… pressure is enabled (ray-project#65136)

## Description

Previously, workers were always subscribing to GCS for owner death
notification, but that was only needed for actor-level backpressure.
This PR makes the subscription only when actor-level backpressure is
enabled.

---------

Signed-off-by: Rueian Huang <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
…r deaths for generator backpressure (ray-project#65195)

## Description

Follow-up to ray-project#65136: instead of the backpressured generator executor
subscribing to all worker failures and filtering client-side, this adds
support for keyed `SubscribeWorkerFailure(worker_id)` to the
pubsub/accessor layers and has the core worker subscribe only to the
owners of the backpressured generator tasks it is actually running.

---------

Signed-off-by: sampan <[email protected]>
Co-authored-by: sampan <[email protected]>
Co-authored-by: Rueian <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
… pressure is enabled (ray-project#65136)

## Description

Previously, workers were always subscribing to GCS for owner death
notification, but that was only needed for actor-level backpressure.
This PR makes the subscription only when actor-level backpressure is
enabled.

---------

Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…r deaths for generator backpressure (ray-project#65195)

## Description

Follow-up to ray-project#65136: instead of the backpressured generator executor
subscribing to all worker failures and filtering client-side, this adds
support for keyed `SubscribeWorkerFailure(worker_id)` to the
pubsub/accessor layers and has the core worker subscribe only to the
owners of the backpressured generator tasks it is actually running.

---------

Signed-off-by: sampan <[email protected]>
Co-authored-by: sampan <[email protected]>
Co-authored-by: Rueian <[email protected]>
Signed-off-by: 400Ping <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
… pressure is enabled (ray-project#65136)

## Description

Previously, workers were always subscribing to GCS for owner death
notification, but that was only needed for actor-level backpressure.
This PR makes the subscription only when actor-level backpressure is
enabled.

---------

Signed-off-by: Rueian Huang <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…r deaths for generator backpressure (ray-project#65195)

## Description

Follow-up to ray-project#65136: instead of the backpressured generator executor
subscribing to all worker failures and filtering client-side, this adds
support for keyed `SubscribeWorkerFailure(worker_id)` to the
pubsub/accessor layers and has the core worker subscribe only to the
owners of the backpressured generator tasks it is actually running.

---------

Signed-off-by: sampan <[email protected]>
Co-authored-by: sampan <[email protected]>
Co-authored-by: Rueian <[email protected]>
sampan-s-nayak added a commit that referenced this pull request Nov 17, 2026
)

## Description

Since #63310, the owner sends `UpdateGeneratorBackpressureConsumed` to
the executor on every read from a backpressured streaming generator. The
gRPC send (`grpc_call_start_batch` / `ExecCtx::Flush`) ran inline on the
reading thread. For Ray Data that thread is the streaming executor's
Python scheduling loop, and Ray Data reads twice per block (block ref +
metadata ref), so it pays for 2 RPC sends per block. This was reported
as ~25% of the driver flame graph and a ~30% drop in task dispatch rate:
#63310 (comment)

This PR posts the send to `io_service_` so the reading thread only pays
for a post. The RPC, its contents and the executor side are unchanged.

## Related issues

Related to #63310 (the performance regression reported in the review
thread above).

## Additional information

Microbenchmark: 8 generators × 20k items, waiting until all items are
reported and then timing only `_next_sync` reads on the driver (4-CPU
dev box, 5 trials):

| Build | µs per read |
|---|---|
| master, backpressure off (no RPC) | ~15 |
| master, `_generator_backpressure_num_objects` set | ~120–155 |
| this PR, `_generator_backpressure_num_objects` set | ~25–52 |

Not a duplicate: I searched open PRs for
`UpdateGeneratorBackpressureConsumed` and "generator backpressure
consumed", and none touch this path. #65136 and #65195 only changed
owner-death subscriptions.

Tests run:
- `python -m pytest -q
python/ray/tests/test_streaming_generator_backpressure.py` → 37 passed
- `pre-commit run` → passed

AI assistance (Claude Code) was used for this change. I reviewed the
diff and ran the tests above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: sampan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core 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