Skip to content

Redirecting process output blocks entire program on Ubuntu #27304

@jnodev

Description

@jnodev

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:

Start sleep test. {
                numberOfProcesses: 5,
                spamSleepInSeconds: 0.1,
                numberOfSleepTests: 3,
                sleepTestDelay: 500,
                sleepTestTolerance: 100,
                redirect: True
            }

------- SLEPT TOO LONG: 8603.7407
------- SLEPT TOO LONG: 8606.5207
------- SLEPT TOO LONG: 8101.826
------- SLEPT TOO LONG: 2674.7937
------- SLEPT TOO LONG: 2674.9363
------- SLEPT TOO LONG: 1638.7887
------- SLEPT TOO LONG: 2282.059
------- SLEPT TOO LONG: 1743.126
------- SLEPT TOO LONG: 1231.055

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 to false in line 20, but this should also be possible with the output redirected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions