From 2a8049e0397d3da9b07eac4e71e720b60880d834 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 10 Dec 2014 16:11:30 -0500 Subject: [PATCH] fix reset of open file limit on OS X, where setrlimit() incompatibility left the user with their default open file limit. This number was frequently too small for even medium-sized sessions, causing the code to open/close files via an LRU cache, and doing this during capture for audio files caused a massive decrease in the effective throughput of the system. --- libs/ardour/globals.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 49852a912e..bed44b5d68 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -215,7 +215,12 @@ lotsa_files_please () if (getrlimit (RLIMIT_NOFILE, &rl) == 0) { - rl.rlim_cur = rl.rlim_max; +#ifdef __APPLE__ + /* See the COMPATIBILITY note on the Apple setrlimit() man page */ + rl.rlim_cur = min ((rlim_t) OPEN_MAX, rl.rlim_max); +#else + rl.rlim_cur = rl.rlim_max; +#endif if (setrlimit (RLIMIT_NOFILE, &rl) != 0) { if (rl.rlim_cur == RLIM_INFINITY) {