Skip to content

25% faster decompression with cloudflare's zlib fork #136

Description

@aminnj

I came across an AWS recommendation to use a fork of zlib that cloudfare maintains because it's faster.

Basically,

git clone https://github.com/cloudflare/zlib.git
cd zlib
./configure --prefix=`pwd`
make
make install

and then to hackily swap between the two

# copy original zlib back
cp ~/julia/julia-1.7.0-beta4/lib/julia/bck_libz.so.1.2.11 ~/julia/julia-1.7.0-beta4/lib/julia/libz.so.1.2.11

# copy cloudflare over original
cp ~/julia/cloudflare/zlib/libz.so.1.2.8 ~/julia/julia-1.7.0-beta4/lib/julia/libz.so.1.2.11

Trying out @btime transcode(ZlibDecompressor, a) between the two on raw compressed basket bytes, I saw between a 25 and 40% speedup. We can still see a similar speedup with

julia> using UnROOT; const t = LazyTree(ROOTFile("Run2012BC_DoubleMuParked_Muons.root"), "Events");

# regular zlib
julia> @btime sum(t.nMuon) # 770.774 ms (11366 allocations: 544.33 MiB)
julia> @btime sum(length,t.Muon_pt) # 5.322 s (18391 allocations: 2.93 GiB)

# cloudflare fork
julia> @btime sum(t.nMuon) # 542.433 ms (11366 allocations: 544.33 MiB)
julia> @btime sum(length,t.Muon_pt) # 3.975 s (18391 allocations: 2.93 GiB)

This was on a x86_64 AMD EPYC 7702P, but hopefully one can reproduce it on other systems. From another thread/PR, I think we wrote down that zlib-ng was giving a 10-15% improvement over the usual zlib library, but this cloudflare fork is even faster!

I bet since it's a fork, not some next-gen rewrite, that it'll be easier to make into binaries (@Moelf ? ;) ). And I think this could benefit many workflows due to ROOT using zlib by default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions