zlib acceleration?

Rainer Müller raimue at macports.org
Fri May 29 05:52:04 PDT 2015


On 2015-05-29 11:21, René J.V. Bertin wrote:
> After re-running the benchmarks with the HEADS from the respective
> implementations, the picture changes and the CloudFlare patch becomes
> much more interesting. The CloudFlare patch in its current form does
> require the -msse4 flag as it uses a crc intrinsic from that instruction
> set. Are there still Macs around that do *not* have SSE 4.1, supposing
> they ever existed (apart from PPC Macs of course)?

There are Macs from 2006/2007 with a 32-bit Intel Core Duo processor
that do not support SSE 4.1. It is doubtful whether the default
compilers on these old platforms support these instruction sets.
However, that should not be a problem, as we could probably exclude
these old Macs by enabling the feature only on recent enough versions of
OS X which require newer processors anyway.


Looking at the CloudFlare patch, the implementation does not seem to
check for availability of the SSE 4 instruction set with CPUID and does
not offer any fallback.

However, the rest of the patch does not look applicable either.
Especially this GPL header here bothers me a lot:
https://github.com/cloudflare/zlib/blob/gcc.amd64/contrib/amd64/crc32-pclmul_asm.S

Furthermore, "Function stolen from linux kernel 3.14.", although they
did not even add any GPL copyright notice to the file:
https://github.com/cloudflare/zlib/blob/gcc.amd64/crc32.c#L244

After applying this to the zlib port, the resulting binary would
certainly be covered by the GPL-2 and not the zlib license anymore. That
would introduce lots of compatibility problems.

Even if this CloudFlare patch offers any performance improvements, the
authors did not bother to implement it the sane way respecting licenses
for further distribution. In this form, it will never be included
upstream and we should not do it either.


The Intel patch looks better, applying zlib license to the files added.
Also it has a check for availability of the SSE 4.2 feature before
execution of the machine instruction.

Unfortunately, I couldn't find any zlib mailing list archive containing
the discussion of including the Intel patches.

Overall I concur with Ryan. Development of an library as mature as zlib
is usually conservative and I would let the upstream maintainers decide
if they want to include these patches in their next release.

Rainer


More information about the macports-users mailing list