-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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] Destruct reply of GRPC as early as possible #14598
[Core] Destruct reply of GRPC as early as possible #14598
Conversation
@@ -62,7 +62,9 @@ class ClientCallImpl : public ClientCall { | |||
/// Constructor. | |||
/// | |||
/// \param[in] callback The callback function to handle the reply. | |||
explicit ClientCallImpl(const ClientCallback<Reply> &callback) : callback_(callback) {} | |||
explicit ClientCallImpl( | |||
const std::function<void(const Status &status, std::shared_ptr<Reply>)> &callback) |
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.
Why not update the definition of ClientCallback
?
@@ -81,16 +83,16 @@ class ClientCallImpl : public ClientCall { | |||
status = return_status_; | |||
} | |||
if (callback_ != nullptr) { | |||
callback_(status, reply_); | |||
callback_(status, std::move(reply_)); |
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.
Moving a shared_ptr seems unnecessary.
auto call = std::make_shared<ClientCallImpl<Reply>>( | ||
[this, callback](const Status &status, std::shared_ptr<Reply> reply) { | ||
if (callback && !main_service_.stopped() && !shutdown_) { | ||
main_service_.post([status, reply, callback] { callback(status, *reply); }); |
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.
It seems that you copied the std::shared_ptr<Reply>
here. I don't know what's the optimization here.
@@ -157,10 +157,11 @@ class ServerCallImpl : public ServerCall { | |||
// We create this before handling the request so that the it can be populated by | |||
// the completion queue in the background if a new request comes in. | |||
factory.CreateCall(); | |||
auto reply = std::make_shared<Reply>(); |
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.
Could you document that we want the reply to be destructed once it's sent instead of being destructed on the next request arriving?
@@ -219,9 +220,6 @@ class ServerCallImpl : public ServerCall { | |||
/// The request message. | |||
Request request_; |
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.
Why not optimize request as well?
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.
Can you update the description?
Hey @wumuzi520 what's the status of this PR? |
Unassign myself as this PR seems to be abandoned |
|
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
|
Hi again! The issue will be closed because there has been no more activity in the 14 days since the last message. Please feel free to reopen or open a new issue if you'd still like it to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for opening the issue! |
Why are these changes needed?
Related issue number
Checks
scripts/format.sh
to lint the changes in this PR.