-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[WIP] Remove ToArray calls on MemoryStream #3797
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
Conversation
…t serializer can handle any padding
Working on a continuation of this PR where I update our Something in the implementation of Some more investigation is needed |
if (!ms.TryGetBuffer(out var buffer) || buffer.Array is null) | ||
return ms.ToArray(); | ||
|
||
return buffer.Array; |
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.
Is it safe to call TryGetBuffer
on a RecyclableMemoryStream
? It looks like this method is not overloaded.
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's safe in the sense that it works but see my comment on the PR, updating to a later version that actually implements it yields some problems under heavy usage.
I have a feeling it sometimes writes at an offset which trygetbuffer does not take into account, not been able to trap it yesterday though
Is this still waiting on some changes, @Mpdreamz? |
@Mpdreamz In a performance analysis, I found this to be a problem in our use-case. Do you need some help, or testing assistance? I think it could make a noticeable difference in performance. |
Hi @Zyklop we are meeting as a team next week in person and spending some time doing some performance deep dives. I've opened #4191 and #4172 as continuations of this branch. It does not tackle everything we want to investigate but its a first step. If you like to share your analysis results feel free to email me them to Any testing you can do is helpful and appreciated as always, keep an eye out next week. |
Closing this as its out of date. |
and try to reuse .Buffer, new serializer can handle any padding at the end.