SHA256
3
0
forked from pool/zlib

Accepting request 138143 from home:mvyskocil:branches:devel:libraries:c_c++

- add longest_match performance patch (fate#314093)
  * suggested by IBM, sent upstream
- rename the main library package to libz1 according Shared
  Library Policy
- profiling build can be enabled via build --with profiling
- use the human-readable package description from zlib.net
- add rpmlintrc

OBS-URL: https://build.opensuse.org/request/show/138143
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/zlib?expand=0&rev=4
This commit is contained in:
Michal Vyskocil 2012-10-15 07:45:19 +00:00 committed by Git OBS Bridge
parent 32d9e928f6
commit e8b526b295
5 changed files with 162 additions and 23 deletions

View File

@ -1,3 +1,3 @@
zlib
libz1
targettype x86 provides "baselibs-x86:<prefix>/lib/libz.so.1"
zlib-devel

View File

@ -0,0 +1,105 @@
# http://mail.madler.net/pipermail/zlib-devel_madler.net/2012-June/002907.html
# http://mail.madler.net/pipermail/zlib-devel_madler.net/2012-August/002977.html
From: Andreas Krebbel krebbel at linux.vnet.ibm.com
Subject: RFC: Improve longest_match performance
The code currently generated for longest_match looks far from optimal
due to a bunch of pointless zero/sign extend instructions.
By just promoting a few data types in the function I was able to get
rid of all but two. The new hotloop is almost half the size of the
original version providing quite a performance win for S/390:
Measured on a zEnterprise z196
zlib compiled with upstream GCC 4.8 branch
32 bit old new
256MB randomdata: 11.65s 10.92s 6.68%
100MB manpages: 4.23s 4.14s 2.17%
217MB PDF: 10.54s 9.44s 11.65%
unaligned ok
256MB randomdata: 10.90s 10.54s 3.41%
100MB manpages: 3.94s 3.87s 1.81%
217MB PDF: 8.77s 8.64s 1.50%
64 bit old new
256MB randomdata: 11.90s 11.43s 4.11%
100MB manpages: 4.51s 4.44s 1.58%
217MB PDF: 10.11s 9.89s 2.22%
unaligned ok
256MB randomdata: 11.51s 11.15s 3.23%
100MB manpages: 4.33s 3.99s 8.52%
217MB PDF: 9.81s 9.02s 8.76%
I also did some measurements on x86 and Power:
For Power (64 bit, unaligned_ok) an additional zero extend
appears. However, the impact is not measurable. There are minor wins
and minor regressions. The overall result is flat.
For Core2 32 bit the patch is a clear winner with up to 9% for the pdf
test. Also on 64 bit the code optimized for Core2 gets a bit smaller
but unfortunately causes some regressions which I cannot explain.
For mainframe customers the performance of zlib is very important so I
would be very happy to see the patch integrated into upstream
zlib. Given that the patch might cause minor regressions on other
targets, would it be possible to enable it arch-dependent?
See below for the patch and some code snippets from my tests.
Bye,
-Andreas-
---
deflate.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
Index: zlib-1.2.7/deflate.c
===================================================================
--- zlib-1.2.7.orig/deflate.c 2012-02-13 01:15:47.000000000 +0100
+++ zlib-1.2.7/deflate.c 2012-09-27 13:39:57.942762946 +0200
@@ -1143,15 +1143,16 @@
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
* match.S. The code will be functionally equivalent.
*/
-local uInt longest_match(s, cur_match)
+local uInt longest_match(s, pcur_match)
deflate_state *s;
- IPos cur_match; /* current match */
+ IPos pcur_match; /* current match */
{
+ ptrdiff_t cur_match = pcur_match; /* extend to pointer width */
unsigned chain_length = s->max_chain_length;/* max hash chain length */
register Bytef *scan = s->window + s->strstart; /* current string */
register Bytef *match; /* matched string */
register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
+ ptrdiff_t best_len = s->prev_length; /* best match length so far */
int nice_match = s->nice_match; /* stop if match long enough */
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
s->strstart - (IPos)MAX_DIST(s) : NIL;
@@ -1166,12 +1167,12 @@
* Try with and without -DUNALIGNED_OK to check.
*/
register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
+ register uInt scan_start = *(ushf*)scan;
+ register uInt scan_end = *(ushf*)(scan+best_len-1);
#else
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
- register Byte scan_end1 = scan[best_len-1];
- register Byte scan_end = scan[best_len];
+ register uInt scan_end1 = scan[best_len-1];
+ register uInt scan_end = scan[best_len];
#endif
/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.

4
zlib-rpmlintrc Normal file
View File

@ -0,0 +1,4 @@
# zlib-devel require libz1 - zlib produces libz, not libzlib
addFilter("zlib-devel.*: W: no-dependency-on zlib*/zlib-libs/libzlib")
# used only if build --with profiling
addFilter("zlib.src.*: W: make-check-outside-check-section time make check")

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Mon Oct 15 07:39:29 UTC 2012 - mvyskocil@suse.com
- add longest_match performance patch (fate#314093)
* suggested by IBM, sent upstream
- rename the main library package to libz1 according Shared
Library Policy
- profiling build can be enabled via build --with profiling
- use the human-readable package description from zlib.net
- add rpmlintrc
-------------------------------------------------------------------
Mon May 7 12:34:45 UTC 2012 - joop.boonen@opensuse.org

View File

@ -15,39 +15,59 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%bcond_with profiling
Name: zlib
Provides: libz
Obsoletes: libz
# bug437293
%ifarch ppc64
Obsoletes: zlib-64bit
%endif
#
Version: 1.2.7
Release: 0
Summary: Data Compression Library
License: Zlib
Group: System/Libraries
Url: http://www.zlib.net/
# git://github.com/kaffeemonster/zlib.git (branch adler32_vec)
Source: http://zlib.net/zlib-%{version}.tar.bz2
Source0: http://zlib.net/zlib-%{version}.tar.bz2
Source1: LICENSE
Source2: baselibs.conf
Source3: zlib-rpmlintrc
#PATCH-FIX-SUSE: fate#314093, sent upstream by IBM
Patch0: zlib-1.2.7-improve-longest_match-performance.patch
BuildRequires: pkgconfig
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# bug437293
%ifarch ppc64
Obsoletes: zlib-64bit
%endif
%description
ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt
(deflate format) and rfc1952.txt (gzip format). These documents are
also available in other formats from
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html.
zlib is designed to be a free, general-purpose, legally unencumbered -- that
is, not covered by any patents -- lossless data-compression library for use on
virtually any computer hardware and operating system. the zlib data format is
itself portable across platforms. unlike the lzw compression method used in
unix compress(1) and in the gif image format, the compression method currently
used in zlib essentially never expands the data. (lzw can double or triple the
file size in extreme cases.) zlib's memory footprint is also independent of the
input data and can be reduced, if necessary, at some cost in compression.
%package -n libz1
Summary: Include Files and Libraries mandatory for Development
Group: Development/Languages/C and C++
Provides: %{name} = %{version}-%{release}
Obsoletes: %{name} < %{version}-%{release}
%description -n libz1
zlib is designed to be a free, general-purpose, legally unencumbered -- that
is, not covered by any patents -- lossless data-compression library for use on
virtually any computer hardware and operating system. the zlib data format is
itself portable across platforms. unlike the lzw compression method used in
unix compress(1) and in the gif image format, the compression method currently
used in zlib essentially never expands the data. (lzw can double or triple the
file size in extreme cases.) zlib's memory footprint is also independent of the
input data and can be reduced, if necessary, at some cost in compression.
%package devel
Summary: Include Files and Libraries mandatory for Development
Group: Development/Languages/C and C++
Requires: glibc-devel
Requires: zlib = %{version}
Requires: libz1 = %{version}
Provides: libz:/usr/include/zlib.h
# bug437293
%ifarch ppc64
@ -73,12 +93,12 @@ libraries.
%prep
%setup -q
%patch0 -p1
%build
export LDFLAGS="-Wl,-z,relro,-z,now"
# Marcus: breaks example64 in 32bit builds.
%define do_profiling 0
%if %{do_profiling}
# Marcus: breaks example64 in 32bit builds, so it's disabled by default
%if %{with profiling}
profiledir=$(mktemp -d)
trap "rm -rf $profiledir" EXIT
CC="gcc" ./configure --shared --prefix=%{_prefix} --libdir=/%{_lib}
@ -96,24 +116,23 @@ make %{?_smp_mflags}
time make check
%install
#mkdir -p %{buildroot}%{_mandir}/man3
mkdir -p %{buildroot}%{_libdir}
%make_install
ln -s -v /%{_lib}/$(readlink %{buildroot}/%{_lib}/libz.so) %{buildroot}%{_libdir}/libz.so
rm -v %{buildroot}/%{_lib}/libz.so
# static lib
mv %{buildroot}/%{_lib}/libz.a %{buildroot}%{_libdir}
# Move .pc file to %{_libdir}
# Move .pc file to _libdir
mv %{buildroot}/%{_lib}/pkgconfig %{buildroot}%{_libdir}
# manpage
install -m 644 zlib.3 %{buildroot}%{_mandir}/man3
install -m 644 zutil.h %{buildroot}%{_includedir}
%post -p /sbin/ldconfig
%post -n libz1 -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%postun -n libz1 -p /sbin/ldconfig
%files
%files -n libz1
%defattr(-,root,root)
/%{_lib}/libz.so.1.2.*
/%{_lib}/libz.so.1