-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Domain.join is suspiciously slow when using systhreads #12948
Comments
I think this intuition may be reasonable? https://github.com/ocaml/ocaml/blob/trunk/otherlibs/systhreads/st_stubs.c#L467 When multiple domains are running, if a domain exit and it is running systhreads, it will forcefully join on all other threads before exiting. (to prevent rogue threads running in the background when the domain has been shut down.) It may be possible to avoid such delay however, I can look at it tomorrow. |
Nevermind my previous comment, this is obviously not related to the forced joined on other systhreads. I think we are indeed hitting the tick thread timeout before it can effectively shut down. Interestingly, there is this old comment here:
I am not sure what is not implemented here? |
Since all FIXMEs in code should have a corresponding issue to track it, this is indeed related to the first issue of #12399 with the suggestion use a condition variable. (Though I do not think anyone realized that this would result in a delay for |
This program spawns a domain that finishes by returning the current time. The main domain joins it to get this time and reports the difference to the time when the join finishes. I get around 50ms (the tick thread timeout?):
I get (with OCaml 5.1.1):
strace -f -tt
shows that a timeout seemed to be the thing that got it going again:If the domain doesn't run the sys-thread, then it's much faster:
This is a (minor) problem for Eio, since the main domain is stuck for up to 50ms joining the domain, when it could be doing other work. For example, here is a trace showing the top domain freezing for a while trying to join the second domain:
(the yellow background shows areas where work is being done)
The text was updated successfully, but these errors were encountered: