Skip to content

reduce the amount of times we rent / return from arraypool #919

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

Merged
merged 3 commits into from
Jul 22, 2020

Conversation

bollhals
Copy link
Contributor

Proposed Changes

We used to copy around the byte buffers multiple times until they were finally consumed. This PR changes it so they're forwarded whenever possible.
This doesn't mean we allocate less, just that we less different memory blocks until we're done with an operation.

This PR also fixes #918 and does some minor cleanup here and there.

Types of Changes

  • Bug fix (non-breaking change which fixes issue BasicGet Payload buffer is "never" returned #918 )
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)

Checklist

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

Further Comments

In order to take over the buffer from Incoming Command, I had to extend the Apigen, I'm not sure whether this is done as you'd want it, but also do we get rid of it now or not? :)

@bollhals
Copy link
Contributor Author

I'll update the post when I get around to compare the perf measurements between this and master. (Should be marginally faster due to not needing to copy around buffers multiple times.)

@bollhals
Copy link
Contributor Author

Before:
image

After:
image

Relevant bits are highlighted for comparison.

  1. ParseBodyFrame: If the whole body is within 1 payload (I'd argue the usual case) then we don't rent / copy a new buffer, we pass on the existing buffer.
  2. HandleBasicDeliver: Instead of renting a new one and copying it over, we pass it along.
  3. IncomingCommand.Dispose: No need to dispose / return anymore, since we always pass the buffer along if there was a body at all.
  4. InboundFrame.Dispose: Only the body of the frames that haven't been taken over are now returned. (Before 25k+145k = 170k, After 15k+105k = 120k => missing 50k are "BasicDeliver payload frames"

@bollhals
Copy link
Contributor Author

Failing test is the breaking public API (Adding the IDisposable).

@michaelklishin
Copy link
Contributor

@bollhals please update the APIApproved.txt file with the generated one as this is a change we intend to make. Thank you.

@bollhals
Copy link
Contributor Author

@bollhals please update the APIApproved.txt file with the generated one as this is a change we intend to make. Thank you.

/fixed

@michaelklishin michaelklishin merged commit 1125283 into rabbitmq:master Jul 22, 2020
@michaelklishin
Copy link
Contributor

Thank you!

@bollhals bollhals deleted the forwardBody branch March 2, 2021 20:51
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.

BasicGet Payload buffer is "never" returned
2 participants