cache the frameHeaderBuffer & rentedArray #911
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Checklist
CONTRIBUTING.md
documentFurther 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:
after: