[serve] Refresh GCS node-info cache off the control loop (async)#64510
Open
johntaylor-cell wants to merge 2 commits into
Open
[serve] Refresh GCS node-info cache off the control loop (async)#64510johntaylor-cell wants to merge 2 commits into
johntaylor-cell wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces an asynchronous mechanism to refresh the cluster node-info cache off the main control loop, preventing slow GCS queries from blocking the controller. The changes include adding a non-blocking refresh_async method to ClusterNodeInfoCache and running a background refresh loop in the controller when RAY_SERVE_ASYNC_NODE_INFO is enabled. The feedback recommends using run_background_task instead of asyncio.ensure_future to avoid garbage collection of the background task, utilizing the get_env_float_positive helper for environment variable parsing, and adding a type hint to the alive_id_set parameter.
3e96a8d to
dcb3ce9
Compare
At high replica counts with direct ingress, the controller's per-loop GCS node-info refresh (ClusterNodeInfoCache.update -> get_all_node_info / get_all_resource_usage) is a synchronous RPC on the event loop. When the query exceeds its deadline during cluster churn (~12K+ nodes/replicas) the blocking call freezes the control loop for the whole RPC, the cache goes stale, and direct-ingress / HAProxy backends empty out. Add RAY_SERVE_ASYNC_NODE_INFO (default off): refactor update() into a pure _compute_snapshot() (no self-mutation, safe in a thread) + _apply_snapshot() (atomic assignment on the event-loop thread). When the flag is on, a background _node_info_refresh_loop runs _compute_snapshot via run_in_executor -- the GCS calls release the GIL (with nogil) so the control loop keeps running while a slow reply is in flight, and reads always see the last complete snapshot. One refresh in flight at a time; the synchronous per-step update() is gated off when async is on. Behavior is unchanged with the flag off: update() still computes and applies the snapshot synchronously (same result as before). At high N it is safe to raise RAY_GCS_RPC_TIMEOUT_S once async is on, since a longer query no longer blocks the loop. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: john.taylor <john.taylor@anyscale.com>
dcb3ce9 to
2f8d7fb
Compare
Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: john.taylor <john.taylor@anyscale.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At high replica counts with direct ingress, the controller's per-loop GCS node-info refresh (ClusterNodeInfoCache.update -> get_all_node_info / get_all_resource_usage) is a synchronous RPC on the event loop. When the query exceeds its deadline during cluster churn (~12K+ nodes/replicas) the blocking call freezes the control loop for the whole RPC, the cache goes stale, and direct-ingress / HAProxy backends empty out.
Add RAY_SERVE_ASYNC_NODE_INFO (default off): refactor update() into a pure _compute_snapshot() (no self-mutation, safe in a thread) + _apply_snapshot() (atomic assignment on the event-loop thread). When the flag is on, a background _node_info_refresh_loop runs _compute_snapshot via run_in_executor -- the GCS calls release the GIL (with nogil) so the control loop keeps running while a slow reply is in flight, and reads always see the last complete snapshot. One refresh in flight at a time; the synchronous per-step update() is gated off when async is on.
Behavior is unchanged with the flag off: update() still computes and applies the snapshot synchronously (same result as before). At high N it is safe to raise RAY_GCS_RPC_TIMEOUT_S once async is on, since a longer query no longer blocks the loop.