ENDIF (CR_DELTA_RPM_SUPPORT)
ENDIF (ENABLE_DRPM)
+# Threaded XZ Compression
+# Note: This option is disabled by default, because Createrepo_c
+# parallelize a lot of tasks (including compression) by default, this
+# only adds extra threads on XZ library level which causes thread bloat
+# and for most usecases doesn't bring any performance boost.
+# On regular hardware (e.g. less-or-equal 4 cores) this option may even
+# cause degradation of performance.
+OPTION(ENABLE_THREADED_XZ_ENCODER "Enable threaded XZ encoder?" OFF)
+IF (ENABLE_THREADED_XZ_ENCODER)
+ ADD_DEFINITIONS("-DENABLE_THREADED_XZ_ENCODER=1")
+ENDIF (ENABLE_THREADED_XZ_ENCODER)
+
# Get package version
INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
SET (VERSION "${CR_MAJOR}.${CR_MINOR}.${CR_PATCH}")
cmake -DPYTHON_DESIRED=3 .
+## Other build options
+
+### ``-DENABLE_LEGACY_WEAKDEPS=ON``
+
+Enable old SUSE weaktags (Default: OFF)
+
+### ``-DENABLE_THREADED_XZ_ENCODER=ON``
+
+Threaded XZ encoding (Default: OFF)
+
+Note: This option is disabled by default, because Createrepo_c
+parallelize a lot of tasks (including compression) by default, this
+only adds extra threads on XZ library level which causes thread bloat
+and for most usecases doesn't bring any performance boost.
+On regular hardware (e.g. less-or-equal 4 cores) this option may even
+cause degradation of performance.
+
+
## Build tarball
utils/make_tarball.sh [git revision]
// Prepare coder/decoder
- if (mode == CR_CW_MODE_WRITE)
- ret = lzma_easy_encoder(stream,
- CR_CW_XZ_COMPRESSION_LEVEL,
- XZ_CHECK);
- else
+ if (mode == CR_CW_MODE_WRITE) {
+
+#ifdef ENABLE_THREADED_XZ_ENCODER
+ // The threaded encoder takes the options as pointer to
+ // a lzma_mt structure.
+ lzma_mt mt = {
+ // No flags are needed.
+ .flags = 0,
+
+ // Let liblzma determine a sane block size.
+ .block_size = 0,
+
+ // Use no timeout for lzma_code() calls by setting timeout
+ // to zero. That is, sometimes lzma_code() might block for
+ // a long time (from several seconds to even minutes).
+ // If this is not OK, for example due to progress indicator
+ // needing updates, specify a timeout in milliseconds here.
+ // See the documentation of lzma_mt in lzma/container.h for
+ // information how to choose a reasonable timeout.
+ .timeout = 0,
+
+ // Use the default preset (6) for LZMA2.
+ // To use a preset, filters must be set to NULL.
+ .preset = LZMA_PRESET_DEFAULT,
+ .filters = NULL,
+
+ // Integrity checking.
+ .check = XZ_CHECK,
+ };
+
+ // Detect how many threads the CPU supports.
+ mt.threads = lzma_cputhreads();
+
+ // If the number of CPU cores/threads cannot be detected,
+ // use one thread.
+ if (mt.threads == 0)
+ mt.threads = 1;
+
+ // If the number of CPU cores/threads exceeds threads_max,
+ // limit the number of threads to keep memory usage lower.
+ const uint32_t threads_max = 2;
+ if (mt.threads > threads_max)
+ mt.threads = threads_max;
+
+ if (mt.threads > 1)
+ // Initialize the threaded encoder
+ ret = lzma_stream_encoder_mt(stream, &mt);
+ else
+#endif
+ // Initialize the single-threaded encoder
+ ret = lzma_easy_encoder(stream,
+ CR_CW_XZ_COMPRESSION_LEVEL,
+ XZ_CHECK);
+
+ } else {
ret = lzma_auto_decoder(stream,
XZ_MEMORY_USAGE_LIMIT,
XZ_DECODER_FLAGS);
+ }
if (ret != LZMA_OK) {
const char *err_msg;