Parallel compression
Sometimes it can be useful to compress large archives in parallel to speedup the task. A common tool on Linux is gzip
gzip data.tarto compress the data.tar archive and obtain the compressed data.tar.gz. To speedup the process there is a parallel implementation pigz available. You can download pigz and compile it using the following code snippt
wget https://github.com/madler/pigz/archive/refs/tags/v2.6.tar.gz
tar -xvf v2.6.tar.gz
cd v.2.6/
makeTo compress the archive in parallel you can run
./v.2.6/pigz -p 12 data.tarwhere -p specifies the pthreads you want to use. In this case we will 12 pthreads to compress the archive. More options are available here.
To combine generating the archive using tar and compression, the following code can be used
tar --use-compress-program="./pigz-2.6/pigz -p 2" -cvf test.tar.gz core.*and the compression will use 2 phtreads.