Skip to content

Process.WaitForExit() gets slower the larger your open file limit (ulimit -n) is on Linux #6555

@akoeplinger

Description

@akoeplinger

Steps to Reproduce

  1. Compile this: csc test.cs:
public static class Program {
    public static int Main () {
        for (int i = 0; i < 100; i++) {
            var p = System.Diagnostics.Process.Start ("echo", "hello");
            if (!p.WaitForExit (10000)) return 1;
        }
        return 0;
    }
}
  1. $ (ulimit -n 1000; time mono test.exe)
...
real	0m0.402s
user	0m0.028s
sys	0m0.184s
  1. $ (ulimit -n 100000; time mono test.exe)
...
real	0m1.277s
user	0m0.380s
sys	0m0.592s
  1. $ (ulimit -n 1000000; time mono test.exe)
...
real	0m8.758s
user	0m3.424s
sys	0m4.424s

Current Behavior

It gets slower the higher your ulimit -n is.

Note: you may need to change your system settings (/etc/security/limits.conf) to allow higher limits.

Expected Behavior

Not getting slower.

On which platforms did you notice this

[ ] macOS
[ X ] Linux, Ubuntu 14.04/16.04
[ ] Windows

Version Used: master, 5.8.088 and 4.2.1 (so either a very old bug or something outside our control)

This was the root cause behind an issue (#6537) we had on Jenkins because the Azure Linux VM builders had ulimit -n set to 1048576.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions