Live data from Hacker News

Pigz: Parallel gzip for modern multi-processor, multi-core machines

zlib.net

11–20 of 197 posts

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#11
post #2

Similarly, for bzip2 there is pbzip2 ( http://compression.great-site.net/pbzip2/?i=1 ). zstd & xz support the "-T" argument for setting thread count. If you pass "-T 0" it will attempt to detect and use a thread per physical core.

I have seen at least one case where pbzip2 created files which could not be opened by some .NET implementation of the decoder, but the same decoder could open files created by lbzip just fine. No idea why.

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#12

Useful with Docker, see https://github.com/moby/moby/pull/35697 I’ve integrated pigz into different build and CI pipelines a few times. Don’t expect wonders since some steps still need to run serially, but a few seconds here and there might still add up to a few minutes on a large build.

I built a custom dpkg with parallel xz for speeding up the compression of large omni style deb packages. Totally worth it.

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#13
The issue with pigz is that uncompressing doesn't really parallelize beyond a three stage read/uncompress/write pipeline.

This is of course more of a problem of the gz format than pigz although last time I looked hacks are possible to parallelize decompression.

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#14

Useful with Docker, see https://github.com/moby/moby/pull/35697 I’ve integrated pigz into different build and CI pipelines a few times. Don’t expect wonders since some steps still need to run serially, but a few seconds here and there might still add up to a few minutes on a large build.

Am I reading correctly that Docker just automatically uses pigz if it’s in the system path? I’ve used both for years and had no idea. I’m definitely going to make sure it’s installed in CI pipelines going forward, I know of some bloated image builds it will definitely help with!

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#17

The issue with pigz is that uncompressing doesn't really parallelize beyond a three stage read/uncompress/write pipeline. This is of course more of a problem of the gz format than pigz although last time I looked hacks are possible to parallelize decompression.

I implemented parallel decompression a while back. It is in Solaris 11.3 and later.

https://github.com/oracle/solaris-userland/blob/master/compo...

Shortly after submitting a PR the code went through major surgery, and my patch then needed a similar amount of surgery. Oracle then whacked most of the Solaris org, and I don’t think this ever got updated to work with the current pigz.

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#18
post #3

Earlier quoted context omitted.

AFAIK (not 100% sure), multithreading support is different - parallel versions split the file in multiple segments, and compress each independently, which multithreaded functionalities apply to the same stream (no hard splitting). For this reason, there's for example pzstd, in addition to zstd.

tangential question: compressed files look like hashes in terms of if something changes in the beginning, all the other parts are different, right?

For compression efficiency, it makes sense to have one large common dictionary. For compression speed, it is easier to have a dictionary per chunk. I still hope they use the common dictionary; if so, any change in the beginning likely affects further parts if it affects the dictionary and thus the way how the later parts are compressed. Same for farther parts affecting the way earlier parts are compressed.

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#19

John Carmack just had a tweet today on this problem: >I started a tar with bzip command on a big directory, and it has been running for two days. Of course, it is only using 1.07 cores out of the 128 available. The Unix pipeline tool philosophy often isn’t aligned with parallel performance. https://twitter.com/ID_AA_Carmack/status/1656708636570271768...

How big is that file... I have 2TB files compressed down to ~300GB and gunzip'ing them takes ~2-3 hours. Granted, that's still a long ass time, but not 2-3 days.

If anything, I wonder what kind of hard drive John has. If you're reading them off a network drive backed by tape drums it's probably going to take a while ;P

Re: Pigz: Parallel gzip for modern multi-processor, multi-core machines

#20
post #3
post #2

Similarly, for bzip2 there is pbzip2 ( http://compression.great-site.net/pbzip2/?i=1 ). zstd & xz support the "-T" argument for setting thread count. If you pass "-T 0" it will attempt to detect and use a thread per physical core.

AFAIK (not 100% sure), multithreading support is different - parallel versions split the file in multiple segments, and compress each independently, which multithreaded functionalities apply to the same stream (no hard splitting). For this reason, there's for example pzstd, in addition to zstd.

Yes, pbzip divides up the file into blocks per core. Though I think some versions (older?) of bzip are unable to handle pbzip archives.

I used pbzip2 on an old octo core xeon server with a decent sas raid and was able to compress at well over 200MB/sec, closer to 300MB in some cases.

Post reply on HN