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

rpc_util: added a byte slice return to recvBufferPool #6605

Closed
wants to merge 12 commits into from

Conversation

efremovmi
Copy link

This PR corrects the operation of the buffer pool for unary methods.

This type of fix adds a buffer back to the pool when used. See more details #6578

RELEASE NOTES: none

efremovmi and others added 2 commits September 4, 2023 15:54
rpc_util: added a byte slice return to recvBufferPool
@efremovmi efremovmi changed the title Correct operation of the pool rpc_util: added a byte slice return to recvBufferPool @efremovmi Sep 5, 2023
@efremovmi efremovmi changed the title rpc_util: added a byte slice return to recvBufferPool @efremovmi rpc_util: added a byte slice return to recvBufferPool Sep 5, 2023
@efremovmi
Copy link
Author

@easwars I can't update label and milestone. Also, some tests are unstable, sometimes they work, and sometimes they don't. Should I try running tests until they stop falling? Can you help me?

@arvindbr8
Copy link
Member

I've rerun the failed test

@easwars easwars added this to the 1.59 Release milestone Sep 5, 2023
@easwars
Copy link
Contributor

easwars commented Sep 5, 2023

@hueypark : Do you have some cycles to review this PR?

server.go Outdated
@@ -1311,6 +1311,9 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
}
return err
}

defer s.opts.recvBufferPool.Put(&d)
Copy link
Contributor

Choose a reason for hiding this comment

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

Buffer pools shouldn't be utilized in the presence of WithStatsHandler, EnableTracing, or binary logging, and thus, they must not be returned to the pool here.

It's essential to verify whether the data is still actively utilized in the contexts mentioned above. Only consider returning it to the pool if it's no longer in use. In df function seems to be the suitable location for this implementation.

Copy link
Author

Choose a reason for hiding this comment

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

@hueypark moved Put to a suitable location.

Copy link
Contributor

Choose a reason for hiding this comment

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

Before returning d to the pool, please ensure it is not in use. Specifically, if either shs or binlogs are present, d should not be returned to the pool.

Copy link
Author

Choose a reason for hiding this comment

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

Corrected it. See if I understood you correctly? If not, can you tell me if there is already something similar in this code base?

Copy link
Contributor

@hueypark hueypark left a comment

Choose a reason for hiding this comment

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

LGTM!

@hueypark
Copy link
Contributor

hueypark commented Sep 7, 2023

@easwars
This PR looks ready for your final review now.

server.go Outdated
@@ -1339,6 +1339,9 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
if trInfo != nil {
trInfo.tr.LazyLog(&payload{sent: false, msg: v}, true)
}
if len(shs) == 0 && len(binlogs) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Should we think about adding a unit test for this conditional?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, having a unit test with a custom recv buffer pool to check that the buffer is released at the end of the RPC would be good.

Copy link
Author

Choose a reason for hiding this comment

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

@arvindbr8 I can't figure out how to do this and how to initialize the stream for the processUnaryRPC function in order to write a unit test. Can you suggest the course of the solution?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a more e2e style test might work better?

  • Create a channel with a custom implementation of the recv buffer pool
  • Perform a unary RPC
  • Once the RPC is completed, ensure that the buffer is returned to your custom pool implementation

This file contains some e2e style tests which you can use as reference: https://github.com/grpc/grpc-go/blob/master/internal/idle/idle_e2e_test.go

Please let us know if you have questions. Thanks.

Copy link
Author

Choose a reason for hiding this comment

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

@easwars Hi, there is no time to finish this task now, as there is a blockage at work and university. Can someone help with completing the task?

Copy link
Contributor

Choose a reason for hiding this comment

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

@efremovmi
I've submitted a pull request and included the relevant tests. #6651
Please feel free to leverage it to finalize your pull request when you have a moment.
If you're unable to do so, just let me know, and I'll proceed with a pull request to close the issue.

Copy link
Author

@efremovmi efremovmi Sep 20, 2023

Choose a reason for hiding this comment

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

Hi! Did I understand correctly that we will make your change, and just close my branch? If so, then please take a look at my last commit and change your code. This change is important because if an error occurs during s.getCodec(stream.ContentSubtype()).Unmarshal(d, v), the buffer will not return to the pool
Снимок экрана 2023-09-20 в 17 01 41

Copy link
Contributor

Choose a reason for hiding this comment

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

Please continue on this PR.
The draft PR I created is for your reference only!

Copy link
Author

Choose a reason for hiding this comment

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

Hi!
@hueypark @easwars @arvindbr8
Check the PR, please

@github-actions
Copy link

This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed.

@efremovmi
Copy link
Author

efremovmi commented Oct 16, 2023

@easwars That's it, did I do it right?

@arvindbr8
Copy link
Member

@efremovmi -- did you mean to close this PR? or close and reopen to force the pre-merge checkers to re-run?

FYI: easwars is out on parental leave. But we will have others on the team to pick this review up.

@efremovmi
Copy link
Author

@arvindbr8 as far as I understood, my corrections were made to the experimental package and in fact this branch is no longer needed (I sent the master to myself and the request pulll closed itself)

@efremovmi
Copy link
Author

Although I may have messed up something...Probably I need to make that change again?

@arvindbr8
Copy link
Member

(I sent the master to myself and the request pulll closed itself)

Would you like us to re-open the issue in that case? @efremovmi

@efremovmi
Copy link
Author

@arvindbr8 Is there an opportunity to continue in this PR? so that the history is stored completely (this is my first PR in open source, I do not know what to do :))

@arvindbr8
Copy link
Member

@efremovmi - mmm, that last force-push seems to have messed up the commit history on your branch. Right now seems like you lost all of the commits made to efremovmi:correct_operation_of_the_pool

do you happen to have a backup of the branch which you could use to restore to the previous snapshot? Feels like you might need some dark git magic to bring your branch back from the grave. 😢

@hueypark
Copy link
Contributor

hueypark commented Nov 3, 2023

@efremovmi If you don't have time to do this now, I'll take over. What do you think?

@efremovmi
Copy link
Author

@hueypark yes, sorry, it's hard to combine work and study. I would be glad if you finished this project

@arvindbr8
Copy link
Member

@efremovmi -- I would suggest that if you have the time to run git reflog in your local to "undo" the force push.

@efremovmi efremovmi reopened this Nov 3, 2023
@efremovmi
Copy link
Author

@arvindbr8 done

Copy link

codecov bot commented Nov 3, 2023

Codecov Report

Merging #6605 (f4c1a7a) into master (70f1a40) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Additional details and impacted files

@arvindbr8
Copy link
Member

Nice! Thanks. Assigning this PR to @hueypark

@hueypark
Copy link
Contributor

hueypark commented Nov 5, 2023

I've created a new PR to cover this issue! Let's continue the discussion from there. #6766

@dfawley
Copy link
Member

dfawley commented Nov 7, 2023

Closing this in favor of #6766

@dfawley dfawley closed this Nov 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants