Repository navigation
[core] Subscribe to specific owner worker deaths instead of all worker deaths for generator backpressure - #65195
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the global subscription to all worker failures with a keyed subscription to individual owner worker failures for generator backpressure cleanup, reducing GCS fan-out overhead. The changes implement keyed subscription and unsubscription APIs across GcsSubscriber, WorkerInfoAccessor, and CoreWorker, handle race conditions and GCS reconnection replays, and update the pubsub subscriber to use insert_or_assign to prevent stale callbacks. Comprehensive unit tests have been added to verify these changes. There are no review comments, so I have no feedback to provide.
7600884 to
a85853a
Compare
…r deaths for generator backpressure Adds a keyed SubscribeWorkerFailure(worker_id) to the pubsub/accessor layers and makes the core worker subscribe only to the owners of the backpressured generator tasks it runs, instead of subscribing to every worker failure in the cluster. The GCS routes keyed subscriptions via its per-entity index, so the fan-out per worker death is O(raylets) + O(interested executors) rather than O(workers). A liveness fetch after each subscribe closes the no-replay window where the owner died before the subscription landed; a missing worker-table row after a successful subscribe is treated as dead since the table only evicts dead entries. Per-worker subscribe operations are replayed by AsyncResubscribe (including the fetch) after GCS failover, and SubscriberChannel keyed subscriptions now use insert_or_assign so a re-subscribed key cannot keep a stale callback. Signed-off-by: sampan <[email protected]>
a85853a to
800b686
Compare
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 67b678c. Configure here.
Signed-off-by: sampan <[email protected]>
67b678c to
3261bc5
Compare
| for (const auto &[_, operation] : per_worker_subscribe_operations_) { | ||
| // nullptr makes the operation fall back to its captured `done` callback, | ||
| // re-running the caller's post-subscribe logic (e.g. the liveness fetch). | ||
| operation(nullptr); |
There was a problem hiding this comment.
These per_worker_subscribe_operations_ are PRCs. Is it possible that we don't run them under the lock? I am worried that we can acquire the lock for too long.
There was a problem hiding this comment.
if its outside lock then parallel unsubscribes may race (currently not a problem as I subscribe and unsubscribe within a lock on core worker end, but given this is a client I thought of trying to keep it safe)
also I feel as this client is per process, there shouldnt be a lot of traffic so slight delays could be acceptable. but let me know what you think
…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]>
…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]>
…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
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.