Replies: 2 comments 1 reply
-
I use that package in several projects, it's been rock solid. If for some reason it wasn't fit for Marten, it would be trivial to build something on top of Microsoft.Extensions.ObjectPool instead. |
Beta Was this translation helpful? Give feedback.
-
Also where possible one could omit to set the ContentLength, e.g.: marten/src/Marten.AspNetCore/QueryableExtensions.cs Lines 49 to 61 in b77d553 ASP.NET Core will produce a "chunked" response then, and afaik every client can handle that. |
Beta Was this translation helpful? Give feedback.
-
For each request a
new MemoryStream
is created, thus also the backingbyte[]
-buffer used by MS and if it needs to be resized another buffer with copying over the old contents, and so on.As response header values can't be set once the body has started, any kind of temporary stream needs to be used -- as it's done now.
But instead of creating a MS every time there should be some kind of pooling, e.g. via Microsoft.IO.RecyclableMemoryStream.
Is this in general something to look into, and is it OK to rely on that package?
Otherwise there could be some inbox-solution for pooled streams based on ArrayPool, etc.
I didn't run any benchmarks so far, just saw this when reading the code.
I can create a PR if needed..
Beta Was this translation helpful? Give feedback.
All reactions