mirror of
https://github.com/Zygo/bees.git
synced 2025-06-17 01:56:16 +02:00
bees: add -G/--thread-min option for minimum thread count
The -g option limits the number of worker threads when the target load average is exceeded. On some systems the load normally runs high, and continuous bees operation is required to avoid running out of disk space. Add a -G/--thread-min option to force at least some threads to continue running. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
14
src/bees.cc
14
src/bees.cc
@ -45,6 +45,7 @@ do_cmd_help(char *argv[])
|
||||
"\t-h, --help\t\tShow this help\n"
|
||||
"\t-c, --thread-count\tWorker thread count (default CPU count * factor)\n"
|
||||
"\t-C, --thread-factor\tWorker thread factor (default " << BEES_DEFAULT_THREAD_FACTOR << ")\n"
|
||||
"\t-G, --thread-min\t\tMinimum worker thread count with load average target (default 0)\n"
|
||||
"\t-g, --loadavg-target\t\tTarget load average for worker threads (default is no target)\n"
|
||||
"\t-m, --scan-mode\t\tScanning mode (0..2, default 0)\n"
|
||||
"\t-t, --timestamps\tShow timestamps in log output (default)\n"
|
||||
@ -653,6 +654,7 @@ bees_main(int argc, char *argv[])
|
||||
bool chatter_prefix_timestamp = true;
|
||||
double thread_factor = 0;
|
||||
unsigned thread_count = 0;
|
||||
unsigned thread_min = 0;
|
||||
double load_target = 0;
|
||||
|
||||
// Parse options
|
||||
@ -661,18 +663,19 @@ bees_main(int argc, char *argv[])
|
||||
int option_index = 0;
|
||||
static const struct option long_options[] = {
|
||||
{ "thread-factor", required_argument, NULL, 'C' },
|
||||
{ "thread-min", required_argument, NULL, 'G' },
|
||||
{ "strip-paths", no_argument, NULL, 'P' },
|
||||
{ "no-timestamps", no_argument, NULL, 'T' },
|
||||
{ "thread-count", required_argument, NULL, 'c' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "loadavg-target", required_argument, NULL, 'g' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "scan-mode", required_argument, NULL, 'm' },
|
||||
{ "absolute-paths", no_argument, NULL, 'p' },
|
||||
{ "timestamps", no_argument, NULL, 't' },
|
||||
{ "verbose", required_argument, NULL, 'v' },
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "C:PTc:hg:m:ptv:", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "C:G:PTc:hg:m:ptv:", long_options, &option_index);
|
||||
if (-1 == c) {
|
||||
break;
|
||||
}
|
||||
@ -682,6 +685,9 @@ bees_main(int argc, char *argv[])
|
||||
case 'C':
|
||||
thread_factor = stod(optarg);
|
||||
break;
|
||||
case 'G':
|
||||
thread_min = stoul(optarg);
|
||||
break;
|
||||
case 'P':
|
||||
crucible::set_relative_path(cwd);
|
||||
break;
|
||||
@ -748,10 +754,12 @@ bees_main(int argc, char *argv[])
|
||||
|
||||
if (load_target != 0) {
|
||||
BEESLOGNOTICE("setting load average target to " << load_target);
|
||||
BEESLOGNOTICE("setting worker thread pool minimum size to " << thread_min);
|
||||
TaskMaster::set_thread_min_count(thread_min);
|
||||
}
|
||||
TaskMaster::set_loadavg_target(load_target);
|
||||
|
||||
BEESLOGNOTICE("setting worker thread pool maximum size to " << load_target);
|
||||
BEESLOGNOTICE("setting worker thread pool maximum size to " << thread_count);
|
||||
TaskMaster::set_thread_count(thread_count);
|
||||
|
||||
// Create a context and start crawlers
|
||||
|
Reference in New Issue
Block a user