-
Notifications
You must be signed in to change notification settings - Fork 824
Use thread pool in StackGuard #18761
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
Conversation
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
Turns out StackGuard starts a surprisingly high number of threads. So many that it starves some 32bit tests. |
d9a8108
to
360379c
Compare
360379c
to
747a332
Compare
Benchmarking this is tricky. |
It seems it is possible to reimplement StackGuard single-threaded, with much better performance. I'll close and work on that instead. |
Thanks for experimenting on this @majocha . |
Yeah, I spoke too soon. I was able with some trickery to get a singlethreaded StackGuard that preserves the very useful type signature of the current one, but it breaks for anything but the most simple cases. Interestingly, in theory it seems possible. Just replace async with some single threaded scheduler and yield instead of SwitchToNewThread(). The tricky part is yielding cooperatively without deadlocking everything. |
Description
Running the task on a thread pool thread is significantly faster than spinning up a new thread.
This could improve performance with codebases that trigger the StackGuard a lot.