Thursday, December 27, 2012

Patch to make xz use all the processor cores

--- xz-5.1.2alpha/src/xz/hardware.c    2012-07-05 01:51:14.000000000 +0800
+++ xz-5.1.2alpha-mt/src/xz/hardware.c    2012-12-27 14:52:25.368253769 +0800
@@ -13,13 +13,13 @@
 #include "private.h"
 #include "tuklib_cpucores.h"


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

 /// Memory usage limit for compression
 static uint64_t memlimit_compress;

 /// Memory usage limit for decompression
 static uint64_t memlimit_decompress;
@@ -45,12 +45,15 @@
 }


 extern uint32_t
 hardware_threads_get(void)
 {
+    if (0 == threads_max)
+        hardware_threads_set(0);
+
     return threads_max;
 }


 extern void
 hardware_memlimit_set(uint64_t new_memlimit,

No comments: