Skip to content

Commit 6daa4d0

Browse files
committed
xz: Use threaded mode by defaut (as if --threads=0 was used).
This hopefully does more good than bad: + It's faster by default. + Only the threaded compressor creates files that can be decompressed in threaded mode. - Compression ratio is worse, usually not too much though. When it matters, -T1 must be used. - Memory usage increases. - Scripts that assume single-threaded mode but don't use -T1 will possibly use too much resources, for example, if they run multiple xz processes in parallel to compress multiple files. - Output from single-threaded and multi-threaded compressors differ but such changes could happen for other reasons too (they just haven't happened since 5.0.0).
1 parent a2dd2dc commit 6daa4d0

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/xz/hardware.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/// Maximum number of worker threads. This can be set with
1717
/// the --threads=NUM command line option.
18-
static uint32_t threads_max = 1;
18+
static uint32_t threads_max;
1919

2020
/// True when the number of threads is automatically determined based
2121
/// on the available hardware threads.
@@ -334,5 +334,9 @@ hardware_init(void)
334334
memlimit_mt_default = mem_ceiling;
335335
#endif
336336

337+
// Enable threaded mode by default. xz 5.4.x and older
338+
// used single-threaded mode by default.
339+
hardware_threads_set(0);
340+
337341
return;
338342
}

src/xz/message.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,8 @@ message_help(bool long_help)
10221022
" does not affect decompressor memory requirements"));
10231023

10241024
puts(_(
1025-
" -T, --threads=NUM use at most NUM threads; the default is 1; set to 0\n"
1026-
" to use as many threads as there are processor cores"));
1025+
" -T, --threads=NUM use at most NUM threads; the default is 0 which uses\n"
1026+
" as many threads as there are processor cores"));
10271027

10281028
if (long_help) {
10291029
puts(_(

src/xz/xz.1

+9
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,15 @@ meet this condition,
13031303
but files compressed in single-threaded mode don't even if
13041304
.BI \-\-block\-size= size
13051305
has been used.
1306+
.IP ""
1307+
The default value for
1308+
.I threads
1309+
is
1310+
.BR 0 .
1311+
In
1312+
.B xz
1313+
5.4.x and older the default is
1314+
.BR 1 .
13061315
.
13071316
.SS "Custom compressor filter chains"
13081317
A custom filter chain allows specifying

0 commit comments

Comments
 (0)