-
Notifications
You must be signed in to change notification settings - Fork 13.3k
tasks hang #3435
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
Comments
Here is the test case. Note that the unit test function actually runs the real test ten times (the real test fails about half the time).
|
Fwiw I was able to run the test case from #2841 five times with no failures. |
Got the above to work by changing uptime_sse to use
Which is the same sort of work around I had to use with #2841. |
Thanks for the good report. I haven't been able to reproduce the deadlock yet but note that
Probably doesn't behave like you want. This won't necessarily give the listeners an 'opportunity to get at least one update'. Is the sleeping critical to the functioning of the test? You might want to experiment with this non-blocking sleep:
|
I suggest always using the above sleep. Calling libc sleep, even if it works, is going to be bad for throughput. |
Only two tasks call sleep: the manage_state task and the unit test task that calls the tester function. The test app uses the first sleep, the second sleep is an artifact of trying to repro the failure in a unit test. |
On my machine the test did pass when I used brson's sleep function. The number of updates each task received was also way more consistent with the uv sleep. |
But my test app still hangs when I try to use uv sleep (nearly certain that the app and all the user libraries it uses just have the one sleep call). |
Thought about this some more and I better understand your point about the badness of libc::sleep. For example, one failure mode would be if both the unit test task and the manage_state task wound up on the thread. Then the unit_test task could do the big sleep potentially blocking the manage_state task. When the unit_test finally stops sleeping the manage_state task would not have nearly enough time to finish its work. This is likely the same problem with my test app: it's a web server with two tasks listening for incoming connections (on different interfaces) and one or more tasks handling requests for a connection. This is using the old rust-socket library which doesn't do anything fancy with scheduling and two of those tasks are pretty much always blocked which could easily hose other tasks. |
That's right. Any task using rust-socket should probably have it's own single-threaded scheduler. |
Is the hang nondeterministic? Can you add print statements to see where they are hanging? Are you convinced that the test code shouldn't hang? |
I think the test should hang...on some systems anyway. I'd like to see some improvements so that other people can avoid the same problems I ran into but those are ticketed separately so I think this issue should be closed. For what it's worth I just finished changing over my socket code and the one place I used libc::sleep to use SingleThreaded and then ManualThreads(2) or (4) to spawn subtasks. Still not sure what the default is (ThreadsPerCore is the logical choice but it and ThreadPerTask are not implemented), but my apps are working great now. |
huh, the documentation doesn't say what the default is. it's |
Hmm, when I try to use ThreadPerCore with spawn_sched I get |
ThreadPerCore is not implemented in the task API, but it is the default mode for the default scheduler. Implementing it though is just a matter of wiring in some existing runtime code. |
I opened #3464 |
Using multiple tasks can result in some tasks that do not start up. I was unable to come up with a simple repro, but I do have a fairly involved one (see below). The failure pattern is very similar to #2841.
This is with rust from master on Sep 1 on a Mac Pro 2009 with four cores.
The text was updated successfully, but these errors were encountered: