]> wimlib.net Git - wimlib/commitdiff
Add --threads option to imagex-optimize
authorEric Biggers <ebiggers3@gmail.com>
Mon, 8 Apr 2013 03:56:01 +0000 (22:56 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 8 Apr 2013 03:56:01 +0000 (22:56 -0500)
doc/imagex-optimize.1.in
programs/imagex.c

index 20041a1ef083c3705d8d1b681c1ac5f6a482bbe7..d5ce76102a712b27eb2b83d9320a69d31e63323f 100644 (file)
@@ -21,7 +21,7 @@ When reading \fIWIMFILE\fR, verify its integrity if the integrity table is
 present; in addition, include an integrity table in the optimized WIM.  If this
 option is not specified, no integrity table is included in the optimized WIM,
 even if there was one in the original WIM.
-.TP 6
+.TP
 \fB--recompress\fR
 Recompress all compressed streams in \fIWIMFILE\fR when rebuilding it.  This
 will increase the time needed to rebuild the WIM, unless the WIM is
@@ -35,6 +35,11 @@ XPRESS compression ratio than Microsoft's software, while it generally provides
 a slightly worse LZX compression ratio than Microsoft's software.  So, you may
 not want to specify \fB--recompress\fR when optimizing a LZX-compressed WIM
 created on Windows.
+.TP
+\fB--threads\fR=\fINUM_THREADS\fR
+Number of threads to use for compressing data.  Default: autodetect (number of
+processors).  This parameter is only meaningful when \fB--recompress\fR is also
+specified.
 
 .SH NOTES
 
index b78fa325abd37488f4954947c15771fe1ac68171..372e115b64509d8b6a85ba72061038160c353aef 100644 (file)
@@ -145,6 +145,7 @@ IMAGEX_PROGNAME" mountrw WIMFILE [IMAGE_NUM | IMAGE_NAME] DIRECTORY\n"
 [OPTIMIZE] =
 T(
 IMAGEX_PROGNAME" optimize WIMFILE [--check] [--recompress]\n"
+"                      [--threads=NUM_THREADS]\n"
 ),
 [SPLIT] =
 T(
@@ -262,6 +263,7 @@ static const struct option mount_options[] = {
 static const struct option optimize_options[] = {
        {T("check"),      no_argument, NULL, IMAGEX_CHECK_OPTION},
        {T("recompress"), no_argument, NULL, IMAGEX_RECOMPRESS_OPTION},
+       {T("threads"),    required_argument, NULL, IMAGEX_THREADS_OPTION},
        {NULL, 0, NULL, 0},
 };
 
@@ -2254,6 +2256,7 @@ imagex_optimize(int argc, tchar **argv)
        const tchar *wimfile;
        off_t old_size;
        off_t new_size;
+       unsigned num_threads = 0;
 
        for_opt(c, optimize_options) {
                switch (c) {
@@ -2264,6 +2267,11 @@ imagex_optimize(int argc, tchar **argv)
                case IMAGEX_RECOMPRESS_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS;
                        break;
+               case IMAGEX_THREADS_OPTION:
+                       num_threads = parse_num_threads(optarg);
+                       if (num_threads == UINT_MAX)
+                               return -1;
+                       break;
                default:
                        usage(OPTIMIZE);
                        return -1;
@@ -2291,7 +2299,8 @@ imagex_optimize(int argc, tchar **argv)
        else
                tprintf(T("%"PRIu64" KiB\n"), old_size >> 10);
 
-       ret = wimlib_overwrite(w, write_flags, 0, imagex_progress_func);
+       ret = wimlib_overwrite(w, write_flags, num_threads,
+                              imagex_progress_func);
 
        if (ret == 0) {
                new_size = file_get_size(argv[0]);