利用多核进行tar + gzip / bzip压缩/解压缩 [英] Utilizing multi core for tar+gzip/bzip compression/decompression

查看:1144
本文介绍了利用多核进行tar + gzip / bzip压缩/解压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用 tar zcvf 进行压缩,并使用 tar zxvf 进行解压缩(由于习惯而使用gzip)。

I normally compress using tar zcvf and decompress using tar zxvf (using gzip due to habit).

我最近获得了具有超线程功能的四核CPU,所以我有8个逻辑核,而且我注意到在压缩/解压缩过程中许多核没有使用。

I've recently gotten a quad core CPU with hyperthreading, so I have 8 logical cores, and I notice that many of the cores are unused during compression/decompression.

有什么办法可以利用未使用的内核来使其更快?

Is there any way I can utilize the unused cores to make it faster?

推荐答案

您可以使用 pigz 代替gzip,后者会在多个内核上进行gzip压缩。代替使用-z选项,可以通过Pigz传递它:

You can use pigz instead of gzip, which does gzip compression on multiple cores. Instead of using the -z option, you would pipe it through pigz:

tar cf - paths-to-archive | pigz > archive.tar.gz

默认情况下,pigz使用可用核心数,如果可以,则使用八个不查询。您可以使用-p n要求更多,例如-p 32. pigz与gzip具有相同的选项,因此您可以使用-9请求更好的压缩。例如,

By default, pigz uses the number of available cores, or eight if it could not query that. You can ask for more with -p n, e.g. -p 32. pigz has the same options as gzip, so you can request better compression with -9. E.g.

tar cf - paths-to-archive | pigz -9 -p 32 > archive.tar.gz

这篇关于利用多核进行tar + gzip / bzip压缩/解压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆