-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add rpc_client interface. #11154
Conversation
@@ -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_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rpc_client_
=>
grpc_client_
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use macro or constexpr
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks!
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.Thanks!
There was a problem hiding this 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?
Will do in next PR. |
Fix part of #10804
The old PR is #10805