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

cache the frameHeaderBuffer & rentedArray #911

Merged
merged 1 commit into from
Jul 10, 2020

Conversation

bollhals
Copy link
Contributor

Proposed Changes

This change adds a byte[6] cache to the SocketFrameHandler instead of stack allocating every time and then calling the Read extension method that then rented another byte[] which then copied the result to the stack allocated span.
=> Simplifies & improves performance.

We might reconsider the stack allocation again if we've moved to NS2.1 (I think this contains a Stream.Read(Span) function)

Also I extended the InboundFrame with the rented array, so one does not have to retrieve it again in the dispose.

Types of Changes

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • 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

(The total execution duration is not relevant here, as it contains the waiting time for input in the socket. Look at the remaining functions. Before ~300ms, after ~200ms)
Performance before:
image

after:
image

@michaelklishin michaelklishin merged commit 6482755 into rabbitmq:master Jul 10, 2020
@michaelklishin
Copy link
Member

Good catch, thank you for your ongoing contributions @bollhals 💯

michaelklishin added a commit that referenced this pull request Jul 10, 2020
cache the frameHeaderBuffer & rentedArray

(cherry picked from commit 6482755)
michaelklishin added a commit that referenced this pull request Jul 12, 2020
@lukebakken lukebakken added this to the 7.0.0 milestone Jul 13, 2020
@bollhals bollhals deleted the cacheFrameHeader branch March 2, 2021 20:50
@lukebakken lukebakken modified the milestones: 8.0.0, 7.0.0 Mar 8, 2022
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