Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] GCS get all actors info no longer need to specify if dead jobs' actors need to be included #34415

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dashboard/modules/snapshot/snapshot_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ async def get_job_submission_info(
async def get_actor_info(
self, limit: int = 1000, timeout: int = SNAPSHOT_API_TIMEOUT_SECONDS
):
# TODO (Alex): GCS still needs to return actors from dead jobs.
request = gcs_service_pb2.GetAllActorInfoRequest()
request.show_dead_jobs = True
request.limit = limit
reply = await self._gcs_actor_info_stub.GetAllActorInfo(
request, timeout=timeout
Expand Down
104 changes: 31 additions & 73 deletions src/ray/gcs/gcs_server/gcs_actor_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,86 +355,44 @@ void GcsActorManager::HandleGetAllActorInfo(rpc::GetAllActorInfoRequest request,
return true;
};

if (request.show_dead_jobs() == false) {
auto total_actors = registered_actors_.size() + destroyed_actors_.size();
reply->set_total(total_actors);

auto count = 0;
auto num_filtered = 0;
for (const auto &iter : registered_actors_) {
if (limit != -1 && count >= limit) {
break;
}

// With filters, skip the actor if it doesn't match the filter.
if (request.has_filters() &&
!filter_fn(request.filters(), iter.second->GetActorTableData())) {
++num_filtered;
continue;
}

count += 1;
*reply->add_actor_table_data() = iter.second->GetActorTableData();
auto total_actors = registered_actors_.size() + destroyed_actors_.size();
reply->set_total(total_actors);

auto count = 0;
auto num_filtered = 0;
for (const auto &iter : registered_actors_) {
if (limit != -1 && count >= limit) {
break;
}

for (const auto &iter : destroyed_actors_) {
if (limit != -1 && count >= limit) {
break;
}
// With filters, skip the actor if it doesn't match the filter.
if (request.has_filters() &&
!filter_fn(request.filters(), iter.second->GetActorTableData())) {
++num_filtered;
continue;
}

count += 1;
*reply->add_actor_table_data() = iter.second->GetActorTableData();
// With filters, skip the actor if it doesn't match the filter.
if (request.has_filters() &&
!filter_fn(request.filters(), iter.second->GetActorTableData())) {
++num_filtered;
continue;
}
reply->set_num_filtered(num_filtered);
RAY_LOG(DEBUG) << "Finished getting all actor info.";
GCS_RPC_SEND_REPLY(send_reply_callback, reply, Status::OK());
return;

count += 1;
*reply->add_actor_table_data() = iter.second->GetActorTableData();
}

RAY_CHECK(request.show_dead_jobs());
// We don't maintain an in-memory cache of all actors which belong to dead
// jobs, so fetch it from redis.
Status status = gcs_table_storage_->ActorTable().GetAll(
[reply, send_reply_callback, limit, request, filter_fn](
absl::flat_hash_map<ActorID, rpc::ActorTableData> &&result) {
auto total_actors = result.size();

reply->set_total(total_actors);
auto arena = reply->GetArena();
RAY_CHECK(arena != nullptr);
auto ptr = google::protobuf::Arena::Create<
absl::flat_hash_map<ActorID, rpc::ActorTableData>>(arena, std::move(result));
auto count = 0;
auto num_filtered = 0;
for (const auto &pair : *ptr) {
if (limit != -1 && count >= limit) {
break;
}
// With filters, skip the actor if it doesn't match the filter.
if (request.has_filters() && !filter_fn(request.filters(), pair.second)) {
++num_filtered;
continue;
}
count += 1;
for (const auto &iter : destroyed_actors_) {
if (limit != -1 && count >= limit) {
break;
}
// With filters, skip the actor if it doesn't match the filter.
if (request.has_filters() &&
!filter_fn(request.filters(), iter.second->GetActorTableData())) {
++num_filtered;
continue;
}

// TODO yic: Fix const cast
reply->mutable_actor_table_data()->UnsafeArenaAddAllocated(
const_cast<rpc::ActorTableData *>(&pair.second));
}
reply->set_num_filtered(num_filtered);
GCS_RPC_SEND_REPLY(send_reply_callback, reply, Status::OK());
RAY_LOG(DEBUG) << "Finished getting all actor info.";
});
if (!status.ok()) {
// Send the response to unblock the sender and free the request.
GCS_RPC_SEND_REPLY(send_reply_callback, reply, status);
count += 1;
*reply->add_actor_table_data() = iter.second->GetActorTableData();
}
reply->set_num_filtered(num_filtered);
RAY_LOG(DEBUG) << "Finished getting all actor info.";
GCS_RPC_SEND_REPLY(send_reply_callback, reply, Status::OK());
}

void GcsActorManager::HandleGetNamedActorInfo(
Expand Down
1 change: 1 addition & 0 deletions src/ray/protobuf/gcs_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ message ListNamedActorsReply {

message GetAllActorInfoRequest {
// Whether or not to filter out actors which belong to dead jobs.
// DEPRECATED: This field is deprecated and will be removed in the future.
bool show_dead_jobs = 1;
// Maximum number of entries to return.
// If not specified, return the whole entries without truncation.
Expand Down