Live data from Hacker News

pigz: A parallel implementation of gzip for multi-core machines

github.com

21–30 of 107 posts

Re: pigz: A parallel implementation of gzip for multi-core machines

#21

Earlier quoted context omitted.

Why use tar | pigz -0 when you can just use tar?

I used tar --use-compress-program="pigz" to create the tar out of billions of files

But what’s confusing everyone is that tar cf - will create the tar without any external compression program needed.

Re: pigz: A parallel implementation of gzip for multi-core machines

#22

Earlier quoted context omitted.

Why use tar | pigz -0 when you can just use tar?

I used tar --use-compress-program="pigz" to create the tar out of billions of files

If you're not going to compress at all, you don't need a compressor at all. All you needed was a .tar and not a .tar.gz

Re: pigz: A parallel implementation of gzip for multi-core machines

#23

Earlier quoted context omitted.

I used tar --use-compress-program="pigz" to create the tar out of billions of files

But what’s confusing everyone is that tar cf - will create the tar without any external compression program needed.

Even the “f -“ option is unneeded as the default is to stream to stdout. Though it’s always a bit scary to not explicitly specify the destination in case your finger slips and the first target is itself a writeable file.

Re: pigz: A parallel implementation of gzip for multi-core machines

#24
post #11

We used this to great effect at Facebook for MySQL backups in the early 2010s. The backup hosts had far more CPU than needed so it was a very nice speed-up over gzip. Eventually we switched to zstd, of course, but pigz never failed us.

Pretty similar to that, we used pigz and netcat to bring up new MySQL read replicas in a chain at line speeds. I recall learning the technique from Tumblr's eng blog. https://engineering.tumblr.com/post/7658008285/efficiently-c...

I wrote that Tumblr eng blog post, glad to see it's still making the rounds! I later joined FB's mysql team a few years after that, although I can't quite remember if FB was still using pigz by that time. (also, hi Eric!)

Separately, at Tumblr I vaguely remember examining some alternative to pigz that was consistently faster at the time (11 years ago) because pigz couldn't parallelize decompression. Can't quite remember the name of the alternative, but it had licensing restrictions which made it less attractive than pigz.

Edit: the old fast alternative I was thinking of is qpress, formerly hosted at http://www.quicklz.com/ but that's no longer online. Googling it now, there are some mirrors and also looks like Percona tools used/bundled it. Not sure if they still do or if they've since switched to zstd.

Re: pigz: A parallel implementation of gzip for multi-core machines

#25

Earlier quoted context omitted.

Maybe I’m missing something, but why send the tar generated stream through a non-compressing compressor when you could just send the tar directly?

I didn't have the tar, I created it using: tar --use-compress-program="pigz -0" ...

But if you don't specify the -z flag when using tar, then it won't be compressed. Why type all that out when omitting one flag does the same thing?

Re: pigz: A parallel implementation of gzip for multi-core machines

#26

On Linux would it Just Work™ if you aliased pigz to gzip as a drop-in replacement?

In theory, most stuff should work as it's 99% compatible, but there might well be something that breaks. Rather than symlinking it or some such, it's better to configure the necessary tools to use the pigz command instead and then you'll at least find out what works.

FWIW, I configure BackupPC to use pigz instead of gzip without any issues.

Re: pigz: A parallel implementation of gzip for multi-core machines

#27
Would not recommend using this in 2022, use zstandard or xzip instead.

zstandard is faster and slightly better compression at speed selection settings that are equivalent to gzip, in addition to having the ability to compress stuff at a much greater ratio, optionally, if you allow it to take more time and cpu resources.

https://gregoryszorc.com/blog/2017/03/07/better-compression-...

Re: pigz: A parallel implementation of gzip for multi-core machines

#28
post #8

If you really want to enable all cores for compression and decompression, give pbzip2 a try. pigz isn't as parallel as pbzip2 http://compression.ca/pbzip2/ *edit, as ac29 mentions below, just use zstdmt. In my quick testing it is approximately 8x faster than pbzip2 and gives better compression ratios. Wall clock time went from 41s to 3.5s for a 3.6GB tar of source, pdfs and images AND the resulting file was smaller.…

on the other hand, bzip2 is pretty much obsoleted now by xzip

Re: pigz: A parallel implementation of gzip for multi-core machines

#30
One interesting trivia is that since ~2020 Docker will transparently use pigz for decompressing container image layers if it's available on the host. This was a nice speedup for us, since we use large container images and automatic scaling for incoming traffic surges.
Post reply on HN