mirror of
https://abf.rosa.ru/djam/rpm.git
synced 2025-02-23 18:33:04 +00:00
Port of multithreaded XZ
This commit is contained in:
parent
c0acc85fcc
commit
867efd5b06
2 changed files with 113 additions and 1 deletions
108
rpm-5.4.10-Multithreaded-XZ.patch
Normal file
108
rpm-5.4.10-Multithreaded-XZ.patch
Normal file
|
@ -0,0 +1,108 @@
|
|||
From 885436e995aa39249a7089bf1f850431ed318b7f Mon Sep 17 00:00:00 2001
|
||||
From: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
|
||||
Date: Tue, 25 Dec 2018 01:04:37 +0300
|
||||
Subject: [PATCH] Multithreaded XZ
|
||||
|
||||
Ported commits 7740d1098642cd42f725fb9a2a3819ceaf51a80b and bec7592a36a2243aa4656afecf3247598baac5ff
|
||||
from RPM4 rpm-4.14.0-rc1 to RPM5 5.4.10 (ROSA)
|
||||
https://github.com/rpm-software-management/rpm/commit/7740d1098642cd42f725fb9a2a3819ceaf51a80b
|
||||
https://github.com/rpm-software-management/rpm/commit/bec7592a36a2243aa4656afecf3247598baac5ff
|
||||
---
|
||||
rpmio/xzdio.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
|
||||
1 file changed, 43 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/rpmio/xzdio.c b/rpmio/xzdio.c
|
||||
index f7a078f..e33f3a4 100644
|
||||
--- a/rpmio/xzdio.c
|
||||
+++ b/rpmio/xzdio.c
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "rpmio_internal.h"
|
||||
#include <rpmmacro.h>
|
||||
#include <rpmcb.h>
|
||||
+#include <ctype.h>
|
||||
|
||||
#if defined(WITH_XZ)
|
||||
|
||||
@@ -33,6 +34,10 @@
|
||||
#endif
|
||||
|
||||
#include "lzma.h"
|
||||
+/* Multithreading support in stable API since xz 5.2.0 */
|
||||
+#if LZMA_VERSION >= 50020002
|
||||
+#define HAVE_LZMA_MT
|
||||
+#endif
|
||||
|
||||
#ifndef LZMA_PRESET_DEFAULT
|
||||
#define LZMA_PRESET_DEFAULT UINT32_C(6)
|
||||
@@ -68,7 +73,9 @@ static XZFILE *xzopen_internal(const char *path, const char *mode, int fdno, int
|
||||
XZFILE *xzfile;
|
||||
lzma_stream tmp;
|
||||
lzma_ret ret;
|
||||
-
|
||||
+#ifdef HAVE_LZMA_MT
|
||||
+ int threads = 0;
|
||||
+#endif
|
||||
for (; *mode != '\0'; mode++) {
|
||||
if (*mode == 'w')
|
||||
encoding = 1;
|
||||
@@ -76,6 +83,21 @@ static XZFILE *xzopen_internal(const char *path, const char *mode, int fdno, int
|
||||
encoding = 0;
|
||||
else if (*mode >= '0' && *mode <= '9')
|
||||
level = (int)(*mode - '0');
|
||||
+ else if (*mode == 'T') {
|
||||
+ if (isdigit(*(mode+1))) {
|
||||
+#ifdef HAVE_LZMA_MT
|
||||
+ threads = atoi(++mode);
|
||||
+#endif
|
||||
+ /* skip past rest of digits in string that atoi()
|
||||
+ * should've processed
|
||||
+ * */
|
||||
+ while(isdigit(*++mode));
|
||||
+ }
|
||||
+#ifdef HAVE_LZMA_MT
|
||||
+ else
|
||||
+ threads = -1;
|
||||
+#endif
|
||||
+ }
|
||||
}
|
||||
if (fdno != -1)
|
||||
fp = fdopen(fdno, encoding ? "w" : "r");
|
||||
@@ -95,7 +117,26 @@ static XZFILE *xzopen_internal(const char *path, const char *mode, int fdno, int
|
||||
xzfile->strm = tmp;
|
||||
if (encoding) {
|
||||
if (xz) {
|
||||
- ret = lzma_easy_encoder(&xzfile->strm, level, LZMA_CHECK_CRC32);
|
||||
+#ifdef HAVE_LZMA_MT
|
||||
+ if (!threads) {
|
||||
+#endif
|
||||
+ ret = lzma_easy_encoder(&xzfile->strm, level, LZMA_CHECK_CRC32);
|
||||
+#ifdef HAVE_LZMA_MT
|
||||
+ } else {
|
||||
+ if (threads == -1)
|
||||
+ threads = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
+ lzma_mt mt_options = {
|
||||
+ .flags = 0,
|
||||
+ .threads = threads,
|
||||
+ .block_size = 0,
|
||||
+ .timeout = 0,
|
||||
+ .preset = level,
|
||||
+ .filters = NULL,
|
||||
+ .check = LZMA_CHECK_SHA256 };
|
||||
+
|
||||
+ ret = lzma_stream_encoder_mt(&xzfile->strm, &mt_options);
|
||||
+ }
|
||||
+#endif
|
||||
} else {
|
||||
lzma_options_lzma options;
|
||||
(void) lzma_lzma_preset(&options, level);
|
||||
@@ -167,7 +208,6 @@ static int xzclose(/*@only@*/ XZFILE *xzfile)
|
||||
lzma_ret ret;
|
||||
size_t n;
|
||||
int rc;
|
||||
-
|
||||
if (!xzfile)
|
||||
return -1;
|
||||
if (xzfile->encoding) {
|
||||
--
|
||||
2.17.1
|
||||
|
6
rpm.spec
6
rpm.spec
|
@ -61,7 +61,7 @@ Summary: The RPM package management system
|
|||
Name: rpm
|
||||
Epoch: 1
|
||||
Version: %{libver}.%{minorver}
|
||||
Release: %{?prereldate:0.%{prereldate}.}80
|
||||
Release: %{?prereldate:0.%{prereldate}.}81
|
||||
License: LGPLv2.1+
|
||||
Group: System/Configuration/Packaging
|
||||
Url: http://rpm5.org/
|
||||
|
@ -530,6 +530,8 @@ Patch518: rpm-5.4.10-fix-egg-info-provides.patch
|
|||
# On some modern files, 'file' reprots '... not stripped, too many notes'
|
||||
Patch519: rpm-5.4.10-debuginfo-too-many-notes.patch
|
||||
|
||||
Patch520: rpm-5.4.10-Multithreaded-XZ.patch
|
||||
|
||||
BuildRequires: autoconf >= 2.57
|
||||
BuildRequires: bzip2-devel
|
||||
BuildRequires: automake >= 1.8
|
||||
|
@ -1195,6 +1197,8 @@ This package contains the RPM API documentation generated in HTML format.
|
|||
%patch518 -p1 -b .egg-info~
|
||||
%patch519 -p1 -b .debug_notes~
|
||||
|
||||
%patch520 -p1 -b .MultithreadedXZ
|
||||
|
||||
#required by P55, P80, P81, P94..
|
||||
./autogen.sh
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue