-
Notifications
You must be signed in to change notification settings - Fork 508
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
stack overflow in nested ThreadPool.scope #751
Comments
It would be nice if you included the code directly here in the issue for posterity, but I don't want to copy it here without permission. In summary:
I'm not surprised that this overflows the stack. The important point is that A quick way to limit this would be to limit how many jobs we split your outer iterator into. By default, our adaptive splitting will aim for about twice the number of threads, in case the workload is not balanced, and then increases the number of splits each time work is stolen. If you called You also have a comment that a direct The example feels very artificial, but I'll trust that it's reasonably representative of something you're actually doing. I hope with a better understanding of rayon's work stealing, you might find a better way to coordinate your cross-threadpool work.
I don't think it will make a difference to your problem, but please try with the most current version when reporting a bug. Rayon 1.3.0 was released in December. |
@cuviper Thanks for your explanation. I have copied example code here. Work stealing thread pool is beneficial for CPU utilization, but may not keep stealing to reach stack limit, or at least document this issue in |
I'm curious -- can you discuss why you're mixing multiple thread pools at all?
We don't really know the stack limit in general, nor can we predict whether the next work we call might use too much stack.
I'm open to better documentation, if we can figure out some good guidance here. Or maybe just a warning of this hazard is better than nothing. The problem can arise for any of the blocking calls -- |
I believe this is possible to hit even with a single thread pool. I have |
not 100% sure but looks like I've got a variant of this problem. In my case it was polars, which has its own thread pool, being invoked from app's par_iter loop. |
Code below can reproduce this error.
output
After debug the coredump file, it seems the error is caused by call
rayon::iter::plumbing::bridge_producer_consumer::helper
recursively, but this error only happen in nested ThreadPool.scope, and can't reproduce in rayon's global threadpool.The text was updated successfully, but these errors were encountered: