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

Add rpc_client interface. #11154

Merged
merged 11 commits into from
Jun 7, 2018
Merged

Conversation

gongweibao
Copy link
Contributor

Fix part of #10804
The old PR is #10805

@gongweibao gongweibao requested review from Yancey1989, jacquesqiao and typhoonzero and removed request for jacquesqiao June 4, 2018 10:56
@@ -205,9 +207,9 @@ class RPCClient {
std::map<std::string, std::shared_ptr<grpc::Channel>> channels_;
std::atomic<int64_t> req_count_{0};
std::mutex mutex_;
static std::unique_ptr<RPCClient> rpc_client_;
static std::unique_ptr<GRPCClient> rpc_client_;
Copy link
Contributor

Choose a reason for hiding this comment

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

rpc_client_

=>

grpc_client_

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.Thanks!


virtual bool Wait() = 0;

static const int64_t rpc_time_out = 600 * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use macro or constexpr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks!


class RPCClient {
public:
virtual bool AsyncSendVariable(const std::string& ep,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can make it shorter like ASendVar, SendVar, AGetVar, GetVar etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Async不建议简写。 改成了类似AsyncSendVar

@@ -43,7 +43,7 @@ class FetchBarrierOp : public framework::OperatorBase {
// For profiling
platform::RecordEvent record_event(Type(), &ctx);

auto rpc_client = detail::RPCClient::GetInstance();
auto rpc_client = detail::GRPCClient::GetInstance();
Copy link
Contributor

Choose a reason for hiding this comment

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

To use the client, better to use the type of base class, since we use a singleton, you can make the base class RPCClient as a singleton, and other clients can inherit from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks!

Copy link
Contributor

@typhoonzero typhoonzero left a comment

Choose a reason for hiding this comment

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

LGTM, just two tiny comments.


virtual void Wait() = 0;

static constexpr int64_t rpc_time_out = 600 * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

600s is a bit long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.Thanks.

}

protected:
virtual void InitImpl() = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not need to be pure virtual, not all implementations need to start an event loop for a client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.Thanks!

Copy link
Contributor

@typhoonzero typhoonzero left a comment

Choose a reason for hiding this comment

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

LGTM++, can you pls add some comments about the RPC client interface?

@gongweibao gongweibao merged commit 2028a8e into PaddlePaddle:develop Jun 7, 2018
@gongweibao
Copy link
Contributor Author

Will do in next PR.

@gongweibao gongweibao deleted the rpcclient branch June 11, 2018 10:52
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.

3 participants