AC_CHECK_HEADERS([error.h])
AC_CHECK_HEADERS([err.h])
+dnl for debuginfod concurrency heuristics
+AC_CHECK_HEADERS([sched.h])
+AC_CHECK_FUNCS([sched_getaffinity])
+AC_CHECK_HEADERS([sys/resource.h])
+AC_CHECK_FUNCS([getrlimit])
+
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -D_GNU_SOURCE"
AC_FUNC_STRERROR_R()
#include "config.h"
#endif
+// #define _GNU_SOURCE
+#ifdef HAVE_SCHED_H
+extern "C" {
+#include <sched.h>
+}
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+extern "C" {
+#include <sys/resource.h>
+}
+#endif
+
extern "C" {
#include "printversion.h"
#include "system.h"
/* Prototype for option handler. */
static error_t parse_opt (int key, char *arg, struct argp_state *state);
+static unsigned default_concurrency();
+
/* Data structure to communicate with argp functions. */
static struct argp argp =
{
static unsigned rescan_s = 300;
static unsigned groom_s = 86400;
static bool maxigroom = false;
-static unsigned concurrency = std::thread::hardware_concurrency() ?: 1;
+static unsigned concurrency = default_concurrency();
static int connection_pool = 0;
static set<string> source_paths;
static bool scan_files = false;
}
+static unsigned
+default_concurrency() // guaranteed >= 1
+{
+ // Prior to PR29975 & PR29976, we'd just use this:
+ unsigned sth = std::thread::hardware_concurrency();
+ // ... but on many-CPU boxes, admins or distros may throttle
+ // resources in such a way that debuginfod would mysteriously fail.
+ // So we reduce the defaults:
+
+ unsigned aff = 0;
+#ifdef HAVE_SCHED_GETAFFINITY
+ {
+ int ret;
+ cpu_set_t mask;
+ CPU_ZERO(&mask);
+ ret = sched_getaffinity(0, sizeof(mask), &mask);
+ if (ret == 0)
+ aff = CPU_COUNT(&mask);
+ }
+#endif
+
+ unsigned fn = 0;
+#ifdef HAVE_GETRLIMIT
+ {
+ struct rlimit rlim;
+ int rc = getrlimit(RLIMIT_NOFILE, &rlim);
+ if (rc == 0)
+ fn = max((rlim_t)1, (rlim.rlim_cur - 100) / 4);
+ // at least 2 fds are used by each listener thread etc.
+ // plus a bunch to account for shared libraries and such
+ }
+#endif
+
+ unsigned d = min(max(sth, 1U),
+ min(max(aff, 1U),
+ max(fn, 1U)));
+ return d;
+}
+
+
+
int
main (int argc, char *argv[])
{
/* If '-C' wasn't given or was given with no arg, pick a reasonable default
for the number of worker threads. */
if (connection_pool == 0)
- connection_pool = std::thread::hardware_concurrency() * 2 ?: 2;
+ connection_pool = default_concurrency();
/* Note that MHD_USE_EPOLL and MHD_USE_THREAD_PER_CONNECTION don't
work together. */
Set the concurrency limit for the scanning queue threads, which work
together to process archives & files located by the traversal thread.
This important for controlling CPU-intensive operations like parsing
-an ELF file and especially decompressing archives. The default is the
-number of processors on the system; the minimum is 1.
+an ELF file and especially decompressing archives. The default is
+related to the number of processors on the system and other
+constraints; the minimum is 1.
.TP
.B "\-C" "\-C=NUM" "\-\-connection\-pool" "\-\-connection\-pool=NUM"
\-C=NUM use a fixed thread pool sized NUM, minimum 2
.TE
-The first mode is a simple and safe configuration based on the number
-of processors. The second mode is suitable for tuned load-limiting
-configurations facing unruly traffic.
+The first mode is a simple and safe configuration related to the
+number of processors and other constraints. The second mode is
+suitable for tuned load-limiting configurations facing unruly traffic.
.TP
.B "\-L"