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

Move the IOCP thread pool on windows to managed code #46610

Closed
davidfowl opened this issue Jan 6, 2021 · 6 comments
Closed

Move the IOCP thread pool on windows to managed code #46610

davidfowl opened this issue Jan 6, 2021 · 6 comments
Assignees
Milestone

Comments

@davidfowl
Copy link
Member

Today the managed thread pool implementation moved worker threads and the gate thread but doesn't include IO threads to handle IOCP completions. Lots of complex logic (like handling multiple app domains) and overhead could be removed (and it would be easier to experiment with) by moving the logic into managed code:

Other benefits include having this pool be usable on the NativeAOT branch (which currently uses the windows thread pool for IOCP).

The other follow on and possibly unrelated item that might be interesting here is looking at unifying/centralizing how we poll for IO similar to how other platforms do (assuming it doesn't regress performance).

cc @kouvel @geoffkizer @stephentoub @jkotas

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Threading untriaged New issue has not been triaged by the area owner labels Jan 6, 2021
@kouvel kouvel removed the untriaged New issue has not been triaged by the area owner label Jan 6, 2021
@kouvel kouvel added this to the 6.0.0 milestone Jan 6, 2021
@kouvel kouvel self-assigned this Jan 6, 2021
@davidfowl
Copy link
Member Author

@kouvel I wonder if it makes sense to use worker threads to dequeue work from the IO Completion Port instead of having different IO threads and worker threads (similar to how we have these time sensitive work items that run after the normal work items).

@kouvel
Copy link
Member

kouvel commented Jan 6, 2021

Yea I think using thread pool threads for polling would be better, maybe not with the time-sensitive queue though, as its latency could be too high. A question may be about cases where having multiple epoll threads is currently better (larger machines), I think the better batching and timing of polls may compensate for it some, depends on the delay/work involved in polling and queuing the completions, and differences in timing with larger batches. On Windows IO completions also run out-of-order and in parallel with normal work items, there would be behavioral differences there that would need to be accounted for / experimented with.

@geoffkizer
Copy link
Contributor

I agree that it would be great to get rid of separate IO threads. This causes some weird issues, e.g. there are no work sharing queues on IO threads (at least last time I checked -- maybe this has changed)?

@kouvel I wonder if it makes sense to use worker threads to dequeue work from the IO Completion Port instead of having different IO threads and worker threads (similar to how we have these time sensitive work items that run after the normal work items).

Trying this out seems pretty straightforward to do, and we can run lots of perf tests like TechEmpower to analyze the impact.

@GSPP
Copy link

GSPP commented Jan 7, 2021

IO threads are a concept that is not widely understood in the .NET community. It would be a useful simplification if this went away.

@mangod9 mangod9 modified the milestones: 6.0.0, 7.0.0 Jul 26, 2021
@davidfowl
Copy link
Member Author

@kouvel this should be closed right?

@kouvel
Copy link
Member

kouvel commented Apr 25, 2022

Yea I think this can be closed, IO completion handling was moved to the portable thread pool implementation and IO completions run on worker threads after #64834. Polling for IO on worker threads needs some experimentation.

@kouvel kouvel closed this as completed Apr 25, 2022
@ghost ghost locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants