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

Pooling of Streams in Marten.AspNetCore.QueryableExtensions #2791

Open
oskardudycz opened this issue Nov 22, 2023 Discussed in #2408 · 1 comment
Open

Pooling of Streams in Marten.AspNetCore.QueryableExtensions #2791

oskardudycz opened this issue Nov 22, 2023 Discussed in #2408 · 1 comment

Comments

@oskardudycz
Copy link
Collaborator

Discussed in #2408

Originally posted by gfoidl December 1, 2022
For each request a new MemoryStream is created, thus also the backing byte[]-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..

@oskardudycz
Copy link
Collaborator Author

@gfoidl volunteered #2783 (comment) to work on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants