-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
HttpClient use ValueTask internally #31623
HttpClient use ValueTask internally #31623
Conversation
Having trouble parsing this... bucket? |
👍 |
A large amount; requiring several buckets; might be a British colloquialism 😄 |
Oh! :-) I thought you were saying something was loading. |
Can you share the code you're using? |
Still playing with it, aside from memory, bit of a (small) gain when single threaded, looking at multithreaded bit of a (small) loss when mutli-threaded (assume contention) https://gist.github.com/benaadams/cd2969e13c582ab4070489b5c585024e (client and server) I thought HttpClient was a good sample candidate (being not propriety, easy to share results) since it has many StateMachineBoxes However, the allocations are still heavy from elsewhere And can't get rid of all of them due to the public api being Task based :-/ Going to see what happens when going a bit deeper e.g. requesting https so including sslstream in the pipeline |
@stephentoub current code for HttpClient with http
"configProperties": {
"System.GC.Server": true,
"System.GC.HeapHardLimit": 20971520
} |
Can you:
That should reduce some of the noise. On top of that, you could use the base HttpMessageInvoker instead of the derived HttpClient. |
Changing to Will reboot and restart, just incase its caused overnight detritus |
I'd guess because you're doing 14 1-byte reads on the response stream. Previously HttpClient was buffering the whole response, so your 1-byte reads were all against a memory stream. |
@benaadams, thanks for this. I'm going to close this for now. Given that there's a small regression when the environment variable isn't set, we should wait to do something like this until it's clearer what the future of the setting will be. |
Test code for HttpClient with http
master
(Task)PR
(ValueTask)SET DOTNET_SYSTEM_THREADING_POOLASYNCVALUETASKS=0
PR
(ValueTask)SET DOTNET_SYSTEM_THREADING_POOLASYNCVALUETASKS=1