diff --git a/src/bees-context.cc b/src/bees-context.cc index 9823011..fd360c5 100644 --- a/src/bees-context.cc +++ b/src/bees-context.cc @@ -29,13 +29,14 @@ BeesFdCache::BeesFdCache() BEESCOUNTADD(open_root_ms, open_timer.age() * 1000); return rv; }); + m_root_cache.max_size(BEES_ROOT_FD_CACHE_SIZE); m_file_cache.func([&](shared_ptr ctx, uint64_t root, uint64_t ino) -> Fd { Timer open_timer; auto rv = ctx->roots()->open_root_ino_nocache(root, ino); BEESCOUNTADD(open_ino_ms, open_timer.age() * 1000); return rv; }); - m_file_cache.max_size(BEES_FD_CACHE_SIZE); + m_file_cache.max_size(BEES_FILE_FD_CACHE_SIZE); } Fd diff --git a/src/bees.cc b/src/bees.cc index ea3e10c..91534ae 100644 --- a/src/bees.cc +++ b/src/bees.cc @@ -19,6 +19,10 @@ #include #include +// setrlimit +#include +#include + #include using namespace crucible; @@ -647,6 +651,17 @@ bees_main(int argc, char *argv[]) BEESLOG("using relative path " << relative_path() << "\n"); } + BEESLOG("setting rlimit NOFILE to " << BEES_OPEN_FILE_LIMIT); + + struct rlimit lim = { + .rlim_cur = BEES_OPEN_FILE_LIMIT, + .rlim_max = BEES_OPEN_FILE_LIMIT, + }; + int rv = setrlimit(RLIMIT_NOFILE, &lim); + if (rv) { + BEESLOG("setrlimit(RLIMIT_NOFILE, { " << lim.rlim_cur << " }): " << strerror(errno)); + }; + // Create a context and start crawlers bool did_subscription = false; while (optind < argc) { diff --git a/src/bees.h b/src/bees.h index 04af577..53ed33c 100644 --- a/src/bees.h +++ b/src/bees.h @@ -75,14 +75,25 @@ const int BEES_PROGRESS_INTERVAL = BEES_STATS_INTERVAL; // Status is output every freakin second. Use a ramdisk. const int BEES_STATUS_INTERVAL = 1; -// Number of FDs to open (not counting 100 roots) -const size_t BEES_FD_CACHE_SIZE = 384; +// Number of file FDs to cache when not in active use +const size_t BEES_FILE_FD_CACHE_SIZE = 4096; + +// Number of root FDs to cache when not in active use +const size_t BEES_ROOT_FD_CACHE_SIZE = 1024; + +// Number of FDs to open (rlimit) +const size_t BEES_OPEN_FILE_LIMIT = (BEES_FILE_FD_CACHE_SIZE + BEES_ROOT_FD_CACHE_SIZE) * 2 + 100; + +// Worker thread limit (more threads may be created, but only this number will be active concurrently) +const size_t BEES_WORKER_THREAD_LIMIT = 128; // Log warnings when an operation takes too long const double BEES_TOO_LONG = 2.5; // Avoid any extent where LOGICAL_INO takes this long -const double BEES_TOXIC_DURATION = 9.9; +// const double BEES_TOXIC_DURATION = 9.9; +// EXPERIMENT: Kernel v4.14+ may let us ignore toxicity +const double BEES_TOXIC_DURATION = BEES_COMMIT_INTERVAL; // How long between hash table histograms const double BEES_HASH_TABLE_ANALYZE_INTERVAL = BEES_STATS_INTERVAL;