From 1fe6b2aa4158516f9c6cf5751cc68aafef1af620 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 10 Sep 2019 13:08:26 +0200 Subject: Make the thread pool queue backlog user configurable Signed-off-by: David Oberhollenzer --- mkfs/options.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'mkfs/options.c') diff --git a/mkfs/options.c b/mkfs/options.c index 7b83ec4..f15569a 100644 --- a/mkfs/options.c +++ b/mkfs/options.c @@ -15,6 +15,7 @@ static struct option long_opts[] = { { "pack-file", required_argument, NULL, 'F' }, { "pack-dir", required_argument, NULL, 'D' }, { "num-jobs", required_argument, NULL, 'j' }, + { "queue-backlog", required_argument, NULL, 'Q' }, { "keep-time", no_argument, NULL, 'k' }, #ifdef HAVE_SYS_XATTR_H { "keep-xattr", no_argument, NULL, 'x' }, @@ -30,7 +31,7 @@ static struct option long_opts[] = { { "help", no_argument, NULL, 'h' }, }; -static const char *short_opts = "F:D:X:c:b:B:d:j:kxoefqhV" +static const char *short_opts = "F:D:X:c:b:B:d:j:Q:kxoefqhV" #ifdef WITH_SELINUX "s:" #endif @@ -65,6 +66,10 @@ static const char *help_string = " the selected compressor. Specify 'help' to\n" " get a list of available options.\n" " --num-jobs, -j Number of compressor jobs to create.\n" +" --queue-backlog, -Q Maximum number of data blocks in the thread\n" +" worker queue before the packer starts waiting\n" +" for the block processors to catch up.\n" +" Defaults to 10 times the number of jobs.\n" " --block-size, -b Block size to use for Squashfs image.\n" " Defaults to %u.\n" " --dev-block-size, -B Device block size to padd the image to.\n" @@ -151,6 +156,7 @@ void process_command_line(options_t *opt, int argc, char **argv) opt->blksz = SQFS_DEFAULT_BLOCK_SIZE; opt->devblksz = SQFS_DEVBLK_SIZE; opt->num_jobs = 1; + opt->max_backlog = 0; for (;;) { i = getopt_long(argc, argv, short_opts, long_opts, NULL); @@ -181,6 +187,9 @@ void process_command_line(options_t *opt, int argc, char **argv) case 'j': opt->num_jobs = strtol(optarg, NULL, 0); break; + case 'Q': + opt->max_backlog = strtol(optarg, NULL, 0); + break; case 'B': opt->devblksz = strtol(optarg, NULL, 0); if (opt->devblksz < 1024) { @@ -240,6 +249,12 @@ void process_command_line(options_t *opt, int argc, char **argv) } } + if (opt->num_jobs < 1) + opt->num_jobs = 1; + + if (opt->max_backlog < 1) + opt->max_backlog = 10 * opt->num_jobs; + if (opt->comp_extra != NULL && strcmp(opt->comp_extra, "help") == 0) { compressor_print_help(opt->compressor); exit(EXIT_SUCCESS); -- cgit v1.2.3