RFR: 8291060: OPEN_MAX is no longer the max limit on macOS >= 10.6 for RLIMIT_NOFILE

David Holmes dholmes at openjdk.org
Wed Jul 27 06:59:40 UTC 2022


On Tue, 26 Jul 2022 21:54:11 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:

> On macOS we are currently using setrlimit(RLIMIT_NOFILE, OPEN_MAX) for MaxFDLimit (it's ON by default), but we can go higher than that. 
> 
> My own testing on macOS 12.3.1 reveals that we can ask for setrlimit(RLIMIT_NOFILE, RLIM_INFINITY), though in reality we will get back 32765, which is still more than OPEN_MAX (10240)

Hi Gerard,

General approach is fine. A couple of nits/suggestions.

Thanks.

src/hotspot/os/bsd/os_bsd.cpp line 1993:

> 1991:     } else {
> 1992:       // On macOS >= 10.6 if we define _DARWIN_UNLIMITED_STREAMS or _DARWIN_C_SOURCE
> 1993:       // (we define _DARWIN_C_SOURCE) we can ask for RLIM_INFINITY

You could fold this information into the comment block below so that it is within the ifdef for APPLE.

src/hotspot/os/bsd/os_bsd.cpp line 1997:

> 1995:       status = setrlimit(RLIMIT_NOFILE, &nbr_files);
> 1996: #ifdef __APPLE__
> 1997:       if (status != 0) {

Should this be

`if (status != 0 && errno == EINVAL)`

so that any other error still gets logged?

src/hotspot/os/bsd/os_bsd.cpp line 2004:

> 2002:         status = setrlimit(RLIMIT_NOFILE, &nbr_files);
> 2003:       }
> 2004: #endif // #ifdef __APPLE__

Nit: don't include #ifdef in the #endif comment

-------------

PR: https://git.openjdk.org/jdk/pull/9650


More information about the hotspot-runtime-dev mailing list