-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Use ArrayPool as default pool fallback #35719
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
Once approved I will start the process of backporting it to 3.1 and 5.0. |
src/Servers/Kestrel/Core/src/Internal/Http/Http1OutputProducer.cs
Outdated
Show resolved
Hide resolved
Can we add some regression tests for this? |
Updated with feedback and unit tests. |
src/Servers/Kestrel/Core/src/Internal/HttpOutputProducerHelper.cs
Outdated
Show resolved
Hide resolved
Wouldn't it be simpler to support a null fake memory owner and just use ArrayPool.Shared? |
What's the benefit? Wouldn't you need to special case returning the array in Dispose() in that case? |
I would understand @davidfowl 's suggestion as replacing |
This code originally came from https://source.dot.net/#System.IO.Pipelines/System/IO/Pipelines/BufferSegment.cs,56 which handles this in a much nicer way IMO. |
What's nicer about BufferSegment's way of doing it? |
It's isolated in the buffer segment and doesn't allocate another kind of |
I am trying to implement what I think you meant ... hope it's worth it. Will do it in a separate branch as I am very not sure about the end result. |
@davidfowl is this what you meant? |
I'll try channeling @davidfowl. Allocating a If Instead the suggestion is to put separate Now I'm going to speak as myself again. This seems like a lot of work to avoid a single extra allocation for aborted requests where the writer needs large buffers. This is a pretty rare scenario that isn't going to be very efficient to begin with. That said, it's not that much extra work I guess. |
…r.cs Co-authored-by: Stephen Halter <halter73@gmail.com>
…r.cs Co-authored-by: Stephen Halter <halter73@gmail.com>
@halter73 now I understand the comment, thanks. |
updated |
@davidfowl are the changes what you expected? |
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1211460440 |
/backport to release/5.0 |
Started backporting to release/5.0: https://github.com/dotnet/aspnetcore/actions/runs/1238671987 |
@sebastienros backporting to release/5.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Use ArrayPool as SlabMemoryPool fallback
Applying: Fix comments
Applying: Typos
Applying: Support increase buffer size
Applying: Add function tests, rename argument
error: sha1 information is lacking or useless (src/Servers/Kestrel/Core/src/Internal/Http/Http1OutputProducer.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0005 Add function tests, rename argument
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
GetFakeMemory()
can throw an exception ifsizeHint
is greater thanMaxPoolSize
. The default pool isPinnedBlockMemoryPool
with a max size of 4096.Fixes #30364