From bc7e3a4dd62baa99dbd1985d329a2a806d59a422 Mon Sep 17 00:00:00 2001 From: AmineChikhaoui Date: Tue, 6 Feb 2018 22:42:02 +0100 Subject: [PATCH] support multi threaded xz encoder, this might be particularly useful in the case of hydra where the overhead of single threaded encoding is more noticeable e.g most of the time spent in "Sending inputs"/"Receiving outputs" is due to compression while the actual upload to the binary cache seems to be negligible. --- src/libutil/compression.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc index 5e2631ba3..aad6e9b5b 100644 --- a/src/libutil/compression.cc +++ b/src/libutil/compression.cc @@ -191,8 +191,13 @@ struct XzSink : CompressionSink XzSink(Sink & nextSink) : nextSink(nextSink) { - lzma_ret ret = lzma_easy_encoder( - &strm, 6, LZMA_CHECK_CRC64); + lzma_mt mt_options = {}; + mt_options.flags = 0; + mt_options.timeout = 300; + mt_options.check = LZMA_CHECK_CRC64; + mt_options.threads = lzma_cputhreads(); + lzma_ret ret = lzma_stream_encoder_mt( + &strm, &mt_options); if (ret != LZMA_OK) throw CompressionError("unable to initialise lzma encoder"); // FIXME: apply the x86 BCJ filter?