]> git.ipfire.org Git - thirdparty/zlib-ng.git/commit
inflate: improve performance of memory copy operations 93/head
authorSebastian Pop <s.pop@samsung.com>
Thu, 16 Mar 2017 15:43:36 +0000 (10:43 -0500)
committerSebastian Pop <s.pop@samsung.com>
Wed, 29 Mar 2017 14:41:39 +0000 (09:41 -0500)
commit029c7e18fb4435c29ef31a14d5d3040cb1a0dca1
tree931fcc905266330d79d9668e2c746b68d91b0c90
parent67f514ab48373f535290c715356693a4bf1207d3
inflate: improve performance of memory copy operations

When memory copy operations happen byte by byte, the processors are unable to
fuse the loads and stores together because of aliasing issues.  This patch
clusters some of the memory copy operations in chunks of 16 and 8 bytes.

For byte memset, the compiler knows how to prepare the chunk to be stored.
When the memset pattern is larger than a byte, this patch builds the pattern for
chunk memset using the same technique as in Simon Hosie's patch
https://codereview.chromium.org/2722063002

This patch improves by 50% the performance of zlib decompression of a 50K PNG on
aarch64-linux and x86_64-linux when compiled with gcc-7 or llvm-5.

The number of executed instructions reported by valgrind --tool=cachegrind
on the decompression of a 50K PNG file on aarch64-linux:
- before the patch:
I   refs:      3,783,757,451
D   refs:      1,574,572,882  (869,116,630 rd   + 705,456,252 wr)

- with the patch:
I   refs:      2,391,899,214
D   refs:        899,359,836  (516,666,051 rd   + 382,693,785 wr)

The compression of a 260MB directory containing the code of llvm into a tar.gz
of 35MB and decompressing that with minigzip -d
on i7-4790K x86_64-linux, it takes 0.533s before the patch and 0.493s with the patch,
on Juno-r0 aarch64-linux A57, it takes 2.796s before the patch and 2.467s with the patch,
on Juno-r0 aarch64-linux A53, it takes 4.055s before the patch and 3.604s with the patch.
Makefile.in
inffast.c
inflate.c
memcopy.h [new file with mode: 0644]