-
Notifications
You must be signed in to change notification settings - Fork 2.1k
limited scalability returning JSON due to ArrayPool contention #4660
Comments
/cc @KrzysztofCwalina @stephentoub @jonmiller @nathana1 - how many RPS is this running at? We did some investigations here in the past but didn't encounter a scenario where the contention was significant after making some changes to fix it. https://github.com/dotnet/corefx/issues/7727 |
This is about 400k rps. |
Parking this in post-v1 for now. When we have more data we can figure out when exactly to take a change related to this. |
@nathana1 it's probably a good time to start taking a look at this now. What kind of data do we have that points to the array pool as an issue? Do we know for sure that we were using the implementation of |
This still repro's in the rtm bits. I'm working on some profiles and I'll send them to you. |
Hi @rynowak, In the various profiles I'm seeing 5-10% spent in spinning in the ArrayPool and the thread time profiles show another 5% spent sleeping in those same locks. I did a quick and dirty prototype (nathana1/corefx@b5ae2a9) where I partition the ArrayPool buckets into subbuckets and lock at that level instead, I see throughput go from 330k rps to 460k rps (and cpu saturation). |
@rynowak can you follow up with @davidfowl on what we wish to do here? |
Is this still an issue after dotnet/coreclr#8209 ? |
Yeah. We should close this. |
When running an mvc json benchmark (https://github.com/aspnet/benchmarks/blob/dev/src/Benchmarks/Controllers/HomeController.cs#L22) on a 48 core machine I'm unable to get above 75% cpu with profiles showing a lot of time blocked in Rent and Return in System.Buffers.DefaultArrayPool.
The issue appears to be that the ArrayPool partitions its locks based on buffer size (
Mvc/src/Microsoft.AspNetCore.Mvc.Core/Internal/MemoryPoolHttpResponseStreamWriterFactory.cs
Line 65 in a78f77a
Mvc/src/Microsoft.AspNetCore.Mvc.Core/Internal/MemoryPoolHttpResponseStreamWriterFactory.cs
Line 65 in a78f77a
We seem to need another level of indirection/partitioning here, not sure if MVC or the ArrayPool is the best place.
The text was updated successfully, but these errors were encountered: