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 thread pool initialization to native side #36789

Merged
merged 3 commits into from
May 28, 2020

Conversation

kouvel
Copy link
Member

@kouvel kouvel commented May 20, 2020

  • Following up from Remove per enqueue volatile check in TheadPool  #36697. Currently the initialization occurs when a static variable is accessed before calling into the VM, and after thinking about it some more the intent and need to initialize the thread pool can be a bit unclear
  • The initialization is specific to this implementation and the managed side doesn't necessarily need to know about it
  • Moved the initialization to the native side similarly to other thread pool APIs
  • Added some more assertions to relevant managed-to-native entry point paths to ensure that they are not called before the thread pool is initialized
  • This adds a non-volatile check when requesting a worker thread, which is already a very slow path. I ran into some issues with testing on the arm64 machine with updated locally built libcoreclr.so, so wasn't able to test that. I looked at the baseline profile and looking at time spent exclusively in ThreadPoolNative::RequestWorkerThread() and what it already does, I don't think the change would result in any significant perf difference.

- Following up from dotnet#36697. Currently the initialization occurs when a static variable is accessed before calling into the VM, and after thinking about it some more the intent and need to initialize the thread pool can be a bit unclear
- The initialization is specific to this implementation and the managed side doesn't necessarily need to know about it
- Moved the initialization to the native side similarly to other thread pool APIs
- Added some more assertions to relevant managed-to-native entry point paths to ensure that they are not called before the thread pool is initialized
- This adds a non-volatile check when requesting a worker thread, which is already a very slow path. I ran into some issues with testing on the arm64 machine with updated locally built libcoreclr.so, so wasn't able to test that. I looked at the baseline profile and looking at time spent exclusively in ThreadPoolNative::RequestWorkerThread() and what it already does, I don't think the change would result in any significant perf difference.
@kouvel kouvel added this to the 5.0 milestone May 20, 2020
@kouvel kouvel self-assigned this May 20, 2020
@kouvel
Copy link
Member Author

kouvel commented May 20, 2020

CC @benaadams @janvorli @stephentoub

Copy link
Member

@benaadams benaadams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One compile error nit

kouvel and others added 2 commits May 20, 2020 19:42
Co-authored-by: Ben Adams <thundercat@illyriad.co.uk>
@kouvel kouvel merged commit 8b57c70 into dotnet:master May 28, 2020
@kouvel kouvel deleted the MoveTheadPoolInit branch May 28, 2020 13:32
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants