replay: increase file descriptor limit macOS (#29346)

* Increase file descriptor limit for replay on macos

* Reword comment

* Move set_file_descriptor_limit to common/util.cc

* Include resource.h header
old-commit-hash: d8bda6feb4
This commit is contained in:
Kacper Rączy 2023-08-14 15:05:27 -07:00 committed by GitHub
parent 1424636288
commit 7f02996102
3 changed files with 21 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <dirent.h>
#include <cassert>
@ -60,6 +61,20 @@ int set_core_affinity(std::vector<int> cores) {
#endif
}
int set_file_descriptor_limit(uint64_t limit_val) {
struct rlimit limit;
int status;
if ((status = getrlimit(RLIMIT_NOFILE, &limit)) < 0)
return status;
limit.rlim_cur = limit_val;
if ((status = setrlimit(RLIMIT_NOFILE, &limit)) < 0)
return status;
return 0;
}
std::string read_file(const std::string& fn) {
std::ifstream f(fn, std::ios::binary | std::ios::in);
if (f.is_open()) {

View File

@ -44,6 +44,7 @@ namespace util {
void set_thread_name(const char* name);
int set_realtime_priority(int level);
int set_core_affinity(std::vector<int> cores);
int set_file_descriptor_limit(uint64_t limit);
// ***** Time helpers *****
struct tm get_time();

View File

@ -6,6 +6,11 @@
#include "tools/replay/replay.h"
int main(int argc, char *argv[]) {
#ifdef __APPLE__
// With all sockets opened, we might hit the default limit of 256 on macOS
util::set_file_descriptor_limit(1024);
#endif
QCoreApplication app(argc, argv);
const QStringList base_blacklist = {"uiDebug", "userFlag"};