mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::fs: Add gauge for rlimit_nofile in support section.
This commit is contained in:
parent
472ce01b50
commit
a867cfa51a
3 changed files with 21 additions and 3 deletions
|
@ -33,6 +33,9 @@ namespace ircd::fs::support
|
|||
// Test if fallocate() is supported at target path
|
||||
bool fallocate(const string_view &path, const write_opts &wopts = write_opts_default);
|
||||
|
||||
// Get the limit for number of opened files
|
||||
size_t rlimit_nofile();
|
||||
|
||||
// Dump information to infolog
|
||||
void dump_info();
|
||||
}
|
||||
|
|
|
@ -1182,9 +1182,7 @@ try
|
|||
|
||||
// limit maxfdto prevent too many small files degrading read perf; too low is
|
||||
// bad for write perf.
|
||||
opts->max_open_files = ircd::info::rlimit_nofile?
|
||||
std::min(ircd::info::rlimit_nofile, 256UL): // limit when rlimit supported
|
||||
256UL; // default when rlimit not supported.
|
||||
opts->max_open_files = fs::support::rlimit_nofile();
|
||||
|
||||
// TODO: Check if these values can be increased; RocksDB may keep
|
||||
// thread_local state preventing values > 1.
|
||||
|
|
17
ircd/fs.cc
17
ircd/fs.cc
|
@ -12,6 +12,7 @@
|
|||
#include <RB_INC_SYS_STAT_H
|
||||
#include <RB_INC_SYS_STATFS_H
|
||||
#include <RB_INC_SYS_STATVFS_H
|
||||
#include <RB_INC_SYS_RESOURCE_H
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <RB_INC_SYS_SYSMACROS_H
|
||||
|
||||
|
@ -283,6 +284,22 @@ catch(const std::system_error &e)
|
|||
throw;
|
||||
}
|
||||
|
||||
#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_NOFILE)
|
||||
size_t
|
||||
ircd::fs::support::rlimit_nofile()
|
||||
{
|
||||
rlimit rlim;
|
||||
syscall(getrlimit, RLIMIT_NOFILE, &rlim);
|
||||
return rlim.rlim_cur;
|
||||
}
|
||||
#else
|
||||
size_t
|
||||
ircd::fs::support::rlimit_nofile()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// fs.h / misc
|
||||
|
|
Loading…
Reference in a new issue