Open kouvel opened 1 year ago
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Author: | kouvel |
---|---|
Assignees: | kouvel, eduardo-vp |
Labels: | `area-System.Threading` |
Milestone: | 8.0.0 |
Using the Windows thread pool
I'm for this experiment but I would say that no matter what we find, we shouldn't default to this.
How come some of these are checked? Are those experiments that were already run?
How come some of these are checked? Are those experiments that were already run?
Yea some of these are complete with some leftover work items tracked in https://github.com/dotnet/runtime/issues/52701 for now.
I'm for this experiment but I would say that no matter what we find, we shouldn't default to this.
We should wait for what we find before making calls like this one. For example, what if we find that Windows thread pool is superior in all dimensions?
We should wait for what we find before making calls like this one. For example, what if we find that Windows thread pool is superior in all dimensions?
To me, it feels like it that decision would fly in the face of attempting to build a consistent platform. Even though we can't do this 100% as platform differences always come through in some APIs, our goal should be to make the platform behavior as consistent as possible across platforms where possible.
Even if it was better on all dimensions, we should default to our managed components over OS ones. We have more control and can provide a more consistent experience. That isn't just about behavior, but also about configuration.
This is why ASP.NET Core has HTTP.sys and Kestrel server implementations but defaults to the managed one (amongst other reasons). We don't need to educate people about configuring register keys to tweak server behavior because we made a decision to use a windows component that relies on those behaviors.
When I think about the changes we made to the threadpool to work around blocking APIs, I think about the lack of control we would have if we delegated elsewhere. We'd need to wait for a new windows version to get this behavior. Seems like a non-starter IMHO.
Yes, it is a tradeoff. We often take advantage of platform-specific capabilities in implementation runtime and libraries implementation to maximize the .NET platform value. For example, async I/O works very differently on Windows vs. Linux, and these differences come through in some APIs. It would not make sense to limit async I/O implementation choices to least common denominator in the name of consistent platform.
When I think about the changes we made to the threadpool to work around blocking APIs,
It is not just that. Windows threadpool is used as an implementation detail for number of Windows subsystems. It means that there are two threadpools running in typical .NET apps. I would expect that switching to Windows threadpool reduces our memory footprint by eliminating the threadpool duplication, especially for smaller apps.
For example, async I/O works very differently on Windows vs. Linux, and these differences come through in some APIs. It would not make sense to limit async I/O implementation choices to least common denominator in the name of consistent platform.
Right, I mentioned this, but we do a good job unifying how they work which got even better when we moved the windows IO polling code to managed code in .NET 7. That reduced the differences between the OSes implementations. This is similar to what libuv does and really any modern platform that does IO. Now if you want to eek the last drop of performance out of the platform then you can opt-into that specific platform implementation and maximize the performance.
I'm just talking about defaults; I think we should bias heavily towards managed by default giving users the option to opt-into OS specific implementations as a principle.
@kouvel what would " Polling for IO on worker threads " look like from where we are today?
This issue tracks some thread pool experiments/investigations that were proposed.
Some leftover work items are tracked in https://github.com/dotnet/runtime/issues/52701.