[Reproducible-commits] [dpkg] 32/54: libdpkg: Add experimental multithreaded xz compressor support

Mattia Rizzolo mattia at debian.org
Fri Jan 15 18:54:01 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 673e96778382fdfbbbce8130cbb95785e7abf39a
Author: Guillem Jover <guillem at debian.org>
Date:   Sun Dec 20 05:57:02 2015 +0100

    libdpkg: Add experimental multithreaded xz compressor support
    
    This should speed up compression on multicore systems. This code has
    only been build tested against latest xz-utils git tree, but not run
    tested, as the package in Debian is too old. Rrquires xz >= 5.2.0.
---
 debian/changelog    |  2 ++
 lib/dpkg/compress.c | 20 +++++++++++++++++++-
 m4/dpkg-libs.m4     |  3 +++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 32bba94..70bde36 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -24,6 +24,8 @@ dpkg (1.18.4) UNRELEASED; urgency=medium
     Fixes CVE-2015-0860.
   * Fix an off-by-one read access in dpkg-deb when parsing ar member names.
     Thanks to Hanno Böck <hanno at hboeck.de>.
+  * Add experimental multithreaded xz compression support in libdpkg, which
+    requires xz >= 5.2.0.
   * Test suite:
     - Improve perl code test coverage.
   * Build system:
diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c
index 3d8de4a..9386bab 100644
--- a/lib/dpkg/compress.c
+++ b/lib/dpkg/compress.c
@@ -527,6 +527,17 @@ static void
 filter_xz_init(struct io_lzma *io, lzma_stream *s)
 {
 	uint32_t preset;
+	lzma_check check = LZMA_CHECK_CRC64;
+#ifdef HAVE_LZMA_MT
+	lzma_mt mt_options = {
+		.flags = 0,
+		.threads = sysconf(_SC_NPROCESSORS_ONLN),
+		.block_size = 0,
+		.timeout = 0,
+		.filters = NULL,
+		.check = check,
+	};
+#endif
 	lzma_ret ret;
 
 	io->status |= DPKG_STREAM_COMPRESS;
@@ -534,7 +545,14 @@ filter_xz_init(struct io_lzma *io, lzma_stream *s)
 	preset = io->params->level;
 	if (io->params->strategy == COMPRESSOR_STRATEGY_EXTREME)
 		preset |= LZMA_PRESET_EXTREME;
-	ret = lzma_easy_encoder(s, preset, LZMA_CHECK_CRC64);
+
+#ifdef HAVE_LZMA_MT
+	mt_options.preset = preset;
+	ret = lzma_stream_encoder_mt(s, &mt_options);
+#else
+	ret = lzma_easy_encoder(s, preset, check);
+#endif
+
 	if (ret != LZMA_OK)
 		filter_lzma_error(io, ret);
 }
diff --git a/m4/dpkg-libs.m4 b/m4/dpkg-libs.m4
index 15c6f8f..3b1ce40 100644
--- a/m4/dpkg-libs.m4
+++ b/m4/dpkg-libs.m4
@@ -61,6 +61,9 @@ AC_DEFUN([DPKG_LIB_ZLIB], [
 # Check for lzma library.
 AC_DEFUN([DPKG_LIB_LZMA], [
   DPKG_WITH_COMPRESS_LIB([liblzma], [lzma.h], [lzma_alone_decoder], [lzma])
+  AC_CHECK_LIB([lzma], [lzma_stream_encoder_mt],
+               [AC_DEFINE([HAVE_LZMA_MT], [1],
+                          [xz multithreaded compression support])])
 ])# DPKG_LIB_LZMA
 
 # DPKG_LIB_BZ2

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list