-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Redirecting process output blocks entire program on Ubuntu #27304
Comments
Looking a bit at the implementation I think the reading the child output is performed on the ThreadPool. |
Thank you for your response. Increasing the minimum amount of threads in the ThreadPool indeed seem to fix the issue at least in the sample program. But I am not sure if that is really a fix or just a work-around. For example when running the sample program with 10 processes, each printing with 2Hz (without raising the minimum thread amount) it takes over a minute before the program is running as expected:
To me that seems really long for the ThreadPool adjusting to the demand. |
Neither. It was to check if that is what we are observing: the blocking reads are starving the threadpool. |
@wtgodbe does this behave better on Windows? Or do the Reads also happen on the ThreadPool? |
@tmds, I would expect a similar issue on Windows, as the pipes created for the redirect FileStreams are currently opened for synchronous rather than overlapped I/O. |
@stephentoub I'd be interested in taking a look into this for Linux/Unix. |
We observe strange behavior on our application, when starting processes with their output redirected. The complete application seems to be affected and gets very slow. This is very notable when the started processes write data to stdout in a medium frequency (e.g. 10 Hz).
We observe this with the current SDK (2.1.401) on Ubuntu 16.04.
I created a minimal repo to reproduce the issue. For future references I also uploaded the files to a gist.
Current behavior
The program starts a script multiple (5) times, which prints to stdout with 10Hz. It then creates a few (3) Tasks, which measure how long a delay takes (should take 500ms). They write "SLEPT TOO LONG" to the console, when the delay exceeds a threshold (100ms).
When I execute the program with
dotnet run
on a decent machine with an i7-6700K CPU @ 4.00GHz, I receive the following output:It seems that the delay that should have taken 500ms, is exceeded by several seconds, especially at the beginning.
Expected behavior
Do not see any "SLEPT TOO LONG". This can be archived by setting
redirect
tofalse
in line 20, but this should also be possible with the output redirected.The text was updated successfully, but these errors were encountered: