Skip to content

Replace Actor Channel's pubsub with grpc - #16723

Closed
wuisawesome wants to merge 25 commits into
ray-project:masterfrom
wuisawesome:grpc_node_pubsub
Closed

wuisawesome wants to merge 25 commits into
ray-project:masterfrom
wuisawesome:grpc_node_pubsub

Conversation

@wuisawesome

@wuisawesome wuisawesome commented Jun 29, 2021 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

This PR removes the usage of the redis actor pubsub channel with the grpc based pubsub.

It should also be more efficient because we should no longer be broadcasting every actor change to every node. Instead nodes should only receive updates from relevant actors.

Related issue number

Checks


namespace pub_internal {

class SubscriptionIndexInterface {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These publisher changes could probably be pulled out into a separate PR, but they're pretty self-contained (makes the SubscriptionIndex follow the same pattern as the subscriber's SubscriberChannel to "properly" support templating.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. This is to put different templated index to the same dict right?

@wuisawesome wuisawesome changed the title [WIP] Grpc node pubsub Replace Actor Channel's pubsub with grpc Jul 1, 2021
@rkooo567 rkooo567 self-assigned this Jul 1, 2021
@ericl ericl self-assigned this Jul 1, 2021
@wuisawesome

Copy link
Copy Markdown
Contributor Author

This isn't ready to merge yet, but most of the logic is here, and I think it would be good to get and some initial thoughts even before all the bugs are fixed up.

@rkooo567

rkooo567 commented Jul 2, 2021

Copy link
Copy Markdown
Contributor

Btw, can you add an unit test that checks if different type of IDs are working properly? (just one unit test to check if ObjectID and NodeID both are working with the subscriber / publisher)

@rkooo567 rkooo567 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General direction lgtm


namespace pub_internal {

class SubscriptionIndexInterface {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. This is to put different templated index to the same dict right?

gcs_address.set_ip_address(client_impl_->GetGcsServerAddress().first);
gcs_address.set_port(client_impl_->GetGcsServerAddress().second);
auto subscription_callback = [actor_id, subscribe](const rpc::PubMessage &message) {
RAY_LOG(ERROR) << "Got a subscription!";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray error log

gcs_address, actor_id.Binary(), subscription_callback,
failure_callback);
return Status::OK();
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you un-indent the else block? That would avoid such a huge diff below which presumably hasn't changed. There's an early return above so it's not needed.

return Status::UnknownError(msg.str());
}

} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please un-indent

// command batch).
RAY_LOG(FATAL)
<< "GCS seems to have died. We've lost our subscription to actor changes.";
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please un-indent

<< "Failed to get gcs server address when init gcs client.";
}
subscriber_ = std::make_unique<pubsub::Subscriber>(
subscriber_id_, /*TODO*/ 10,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the real variable name here instead of TODO

// If there's no more subscription, do nothing.
if (subscription_it == subscription_map_.end()) {
for (const auto &pair : subscription_map_) {
RAY_LOG(ERROR) << "\t" << pair.first;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray error

grpc_publisher_.RegisterSubscription(command.channel_type(), subscriber_id,
command.key_id());
} else {
RAY_LOG(ERROR) << "Invalid command has received, "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to RAY_LOG(FATAL) and remove the GitHub message.

"Github.";
std::stringstream stream;
stream << "Invalid pubsub command received: " << request.DebugString();
status = Status::Invalid(stream.str());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this after FATAL


/// This implementation class of `PublisherHandler`
/// All non-handler public methods are threadsafe.
class GcsPublisherManager : public rpc::PublisherHandler {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call it *Handler since it's just a rpc handler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the convention is Manager since I suppose it manages the lifecycle of the pubsub module? For example, GcsHeartbeatManager also doesn't really manage anything.

/// The thread + io service the publisher runs on.
std::unique_ptr<std::thread> publisher_thread_;
instrumented_io_context &publisher_service_;
PeriodicalRunner periodical_runner_;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't seem to ever use this member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants