Repository navigation
[core] only let worker subscribe to owner death when actor level back pressure is enabled - #65136
Conversation
…pressure is enabled Signed-off-by: Rueian Huang <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit b413529. Configure here.
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
fcc54fc to
e8659c2
Compare
…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]>
… 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]>
…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]>
… 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]>
…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]>
… 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]>
…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]>
) ## 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]>

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.