@@ -131,6 +131,20 @@ GcsServer::GcsServer(const ray::gcs::GcsServerConfig &config,
131131 });
132132 });
133133 }),
134+ resource_load_pull_client_call_manager_(
135+ io_context_provider_.GetIOContext<GcsResourceLoadPuller>(),
136+ /* record_stats=*/ true,
137+ config.node_ip_address,
138+ ClusterID::Nil(),
139+ /* num_threads=*/ 1),
140+ resource_load_pull_raylet_client_pool_([this ](const rpc::Address &addr) {
141+ // GetResourceLoad is not retryable, so the unavailable-timeout callback
142+ // can never fire; the puller's snapshot diff evicts instead.
143+ return std::make_shared<ray::rpc::RayletClient>(
144+ addr,
145+ this ->resource_load_pull_client_call_manager_ ,
146+ /* raylet_unavailable_timeout_callback=*/ []() {});
147+ }),
134148 event_aggregator_client_call_manager_ (
135149 io_context_provider_.GetIOContext<observability::RayEventRecorder>(),
136150 /* record_stats=*/ true,
@@ -154,6 +168,8 @@ GcsServer::GcsServer(const ray::gcs::GcsServerConfig &config,
154168 io_context_provider_.GetIOContext<pubsub::GcsPublisher>())),
155169 observability_pubsub_periodical_runner_(PeriodicalRunner::Create(
156170 io_context_provider_.GetIOContext<pubsub::ObservabilityPublisher>())),
171+ resource_load_pull_periodical_runner_(PeriodicalRunner::Create(
172+ io_context_provider_.GetIOContext<GcsResourceLoadPuller>())),
157173 periodical_runner_(
158174 PeriodicalRunner::Create (io_context_provider_.GetDefaultIOContext())),
159175 is_started_(false ),
@@ -500,35 +516,35 @@ void GcsServer::InitGcsResourceManager(const GcsInitData &gcs_init_data) {
500516 *gcs_resource_manager_,
501517 RayConfig::instance ().gcs_max_active_rpcs_per_handler ()));
502518
503- periodical_runner_->RunFnPeriodically (
519+ resource_load_puller_ = std::make_unique<GcsResourceLoadPuller>(
520+ io_context_provider_.GetIOContext <GcsResourceLoadPuller>(),
521+ io_context_provider_.GetDefaultIOContext (),
522+ resource_load_pull_raylet_client_pool_,
523+ /* apply_on_main=*/
524+ [this ](rpc::ResourcesData resources) {
525+ // TODO(vitsai): Remove duplicate reporting to GcsResourceManager
526+ // after verifying that non-autoscaler paths are taken care of.
527+ // Currently, GcsResourceManager aggregates reporting from different
528+ // sources at different intervals, leading to an obviously inconsistent
529+ // view.
530+ //
531+ // Once autoscaler is completely moved to the new mode of consistent
532+ // per-node reporting, remove this if it is not needed anymore.
533+ gcs_resource_manager_->UpdateResourceLoads (resources);
534+ gcs_autoscaler_state_manager_->UpdateResourceLoadAndUsage (std::move (resources));
535+ });
536+ resource_load_pull_periodical_runner_->RunFnPeriodically (
504537 [this ] {
505- for (const auto &alive_node : gcs_node_manager_->GetAllAliveNodes ()) {
506- auto remote_address = rpc::RayletClientPool::GenerateRayletAddress (
538+ const auto alive_nodes = gcs_node_manager_->GetAllAliveNodes ();
539+ std::vector<rpc::Address> raylet_addresses;
540+ raylet_addresses.reserve (alive_nodes.size ());
541+ for (const auto &alive_node : alive_nodes) {
542+ raylet_addresses.push_back (rpc::RayletClientPool::GenerateRayletAddress (
507543 alive_node.first ,
508544 alive_node.second ->node_manager_address (),
509- alive_node.second ->node_manager_port ());
510- auto raylet_client = raylet_client_pool_.GetOrConnectByAddress (remote_address);
511-
512- // GetResourceLoad will also get usage. Historically it didn't.
513- raylet_client->GetResourceLoad ([this ](auto &status, auto &&load_and_usage) {
514- if (status.ok ()) {
515- // TODO(vitsai): Remove duplicate reporting to GcsResourceManager
516- // after verifying that non-autoscaler paths are taken care of.
517- // Currently, GcsResourceManager aggregates reporting from different
518- // sources at different intervals, leading to an obviously inconsistent
519- // view.
520- //
521- // Once autoscaler is completely moved to the new mode of consistent
522- // per-node reporting, remove this if it is not needed anymore.
523- gcs_resource_manager_->UpdateResourceLoads (load_and_usage.resources ());
524- gcs_autoscaler_state_manager_->UpdateResourceLoadAndUsage (
525- std::move (*load_and_usage.mutable_resources ()));
526- } else {
527- RAY_LOG_EVERY_N (WARNING , 10 )
528- << " Failed to get the resource load: " << status.ToString ();
529- }
530- });
545+ alive_node.second ->node_manager_port ()));
531546 }
547+ resource_load_puller_->Pull (std::move (raylet_addresses));
532548 },
533549 RayConfig::instance ().gcs_pull_resource_loads_period_milliseconds (),
534550 " RayletLoadPulled" );
0 commit comments