mirror of
				https://github.com/Zygo/bees.git
				synced 2025-11-04 04:00:36 +01:00 
			
		
		
		
	throttle: add --throttle-factor option to control throttling factor
Also change the initializer syntax for the option list to use C99 compound literals. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
		@@ -12,6 +12,7 @@ Load management options:
 | 
				
			|||||||
    -C, --thread-factor   Worker thread factor (default 1)
 | 
					    -C, --thread-factor   Worker thread factor (default 1)
 | 
				
			||||||
    -G, --thread-min      Minimum worker thread count (default 0)
 | 
					    -G, --thread-min      Minimum worker thread count (default 0)
 | 
				
			||||||
    -g, --loadavg-target  Target load average for worker threads (default none)
 | 
					    -g, --loadavg-target  Target load average for worker threads (default none)
 | 
				
			||||||
 | 
					        --throttle-factor Idle time between operations (default 1.0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Filesystem tree traversal options:
 | 
					Filesystem tree traversal options:
 | 
				
			||||||
    -m, --scan-mode       Scanning mode (0..4, default 4)
 | 
					    -m, --scan-mode       Scanning mode (0..4, default 4)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										36
									
								
								src/bees.cc
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								src/bees.cc
									
									
									
									
									
								
							@@ -716,20 +716,25 @@ bees_main(int argc, char *argv[])
 | 
				
			|||||||
	BeesRoots::ScanMode root_scan_mode = BeesRoots::SCAN_MODE_EXTENT;
 | 
						BeesRoots::ScanMode root_scan_mode = BeesRoots::SCAN_MODE_EXTENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Configure getopt_long
 | 
						// Configure getopt_long
 | 
				
			||||||
 | 
						// Options with no short form
 | 
				
			||||||
 | 
						enum {
 | 
				
			||||||
 | 
							BEES_OPT_THROTTLE_FACTOR = 256,
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
	static const struct option long_options[] = {
 | 
						static const struct option long_options[] = {
 | 
				
			||||||
		{ "thread-factor",         required_argument, NULL, 'C' },
 | 
							{ .name = "thread-factor",         .has_arg = required_argument, .val = 'C' },
 | 
				
			||||||
		{ "thread-min",            required_argument, NULL, 'G' },
 | 
							{ .name = "throttle-factor",       .has_arg = required_argument, .val = BEES_OPT_THROTTLE_FACTOR },
 | 
				
			||||||
		{ "strip-paths",           no_argument,       NULL, 'P' },
 | 
							{ .name = "thread-min",            .has_arg = required_argument, .val = 'G' },
 | 
				
			||||||
		{ "no-timestamps",         no_argument,       NULL, 'T' },
 | 
							{ .name = "strip-paths",           .has_arg = no_argument,       .val = 'P' },
 | 
				
			||||||
		{ "workaround-btrfs-send", no_argument,       NULL, 'a' },
 | 
							{ .name = "no-timestamps",         .has_arg = no_argument,       .val = 'T' },
 | 
				
			||||||
		{ "thread-count",          required_argument, NULL, 'c' },
 | 
							{ .name = "workaround-btrfs-send", .has_arg = no_argument,       .val = 'a' },
 | 
				
			||||||
		{ "loadavg-target",        required_argument, NULL, 'g' },
 | 
							{ .name = "thread-count",          .has_arg = required_argument, .val = 'c' },
 | 
				
			||||||
		{ "help",                  no_argument,       NULL, 'h' },
 | 
							{ .name = "loadavg-target",        .has_arg = required_argument, .val = 'g' },
 | 
				
			||||||
		{ "scan-mode",             required_argument, NULL, 'm' },
 | 
							{ .name = "help",                  .has_arg = no_argument,       .val = 'h' },
 | 
				
			||||||
		{ "absolute-paths",        no_argument,       NULL, 'p' },
 | 
							{ .name = "scan-mode",             .has_arg = required_argument, .val = 'm' },
 | 
				
			||||||
		{ "timestamps",            no_argument,       NULL, 't' },
 | 
							{ .name = "absolute-paths",        .has_arg = no_argument,       .val = 'p' },
 | 
				
			||||||
		{ "verbose",               required_argument, NULL, 'v' },
 | 
							{ .name = "timestamps",            .has_arg = no_argument,       .val = 't' },
 | 
				
			||||||
		{ 0, 0, 0, 0 },
 | 
							{ .name = "verbose",               .has_arg = required_argument, .val = 'v' },
 | 
				
			||||||
 | 
							{ 0 },
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Build getopt_long's short option list from the long_options table.
 | 
						// Build getopt_long's short option list from the long_options table.
 | 
				
			||||||
@@ -766,6 +771,9 @@ bees_main(int argc, char *argv[])
 | 
				
			|||||||
			case 'C':
 | 
								case 'C':
 | 
				
			||||||
				thread_factor = stod(optarg);
 | 
									thread_factor = stod(optarg);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
								case BEES_OPT_THROTTLE_FACTOR:
 | 
				
			||||||
 | 
									bees_throttle_factor = stod(optarg);
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
			case 'G':
 | 
								case 'G':
 | 
				
			||||||
				thread_min = stoul(optarg);
 | 
									thread_min = stoul(optarg);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
@@ -851,6 +859,8 @@ bees_main(int argc, char *argv[])
 | 
				
			|||||||
	BEESLOGNOTICE("setting worker thread pool maximum size to " << thread_count);
 | 
						BEESLOGNOTICE("setting worker thread pool maximum size to " << thread_count);
 | 
				
			||||||
	TaskMaster::set_thread_count(thread_count);
 | 
						TaskMaster::set_thread_count(thread_count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						BEESLOGNOTICE("setting throttle factor to " << bees_throttle_factor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Set root path
 | 
						// Set root path
 | 
				
			||||||
	string root_path = argv[optind++];
 | 
						string root_path = argv[optind++];
 | 
				
			||||||
	BEESLOGNOTICE("setting root path to '" << root_path << "'");
 | 
						BEESLOGNOTICE("setting root path to '" << root_path << "'");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user