pigz, unpigz It means that “A parallel implementation of gzip for modern multi-processor, multi-core machines”
pigz, which stands for parallel implementation of gzip, is a fully functional replacement for gzip that exploits multiple processors and multiple cores to the hilt when compressing data. pigz was written by Mark Adler, and uses the zlib and pthread libraries.
DESCRIPTION Pigz compresses using threads to make use of multiple processors and cores. The input is broken up into 128 KB chunks with each compressed in parallel. The individual check value for eachchunk is also calculated in parallel. The compressed data is written in order to the output, and acombined check value is calculated from the individual check values.
The compressed data for mat generated is in the gzip, zlib, or single-entr y zip for mat using the deflate compression method. The compression produces partial raw deflate streams which are concatenated byasingle write thread and wrapped with the appropriate header and trailer, where the trailer contains the combined check value.
Each partial raw deflate stream is terminated by an empty stored block (using the Z_SYNC_FLUSH option of zlib), in order to end that partial bit stream at a byte boundary. That allows the partial streams to be concatenated simply as sequences of bytes. This adds a ver y small four to five byte overhead to the output for each input chunk.
The default input block size is 128K, but can be changed with the -b option. The number of compress threads is set by default to the number of online processors, which can be changed using the -p option. Specifying -p 1 avoids the use of threads entirely.
The input blocks, while compressed independently, have the last 32K of the previous block loaded as a preset dictionary to preser ve the compression effectiveness of deflating in a single thread.This can be turned off using the -i or --independent option, so that the blocks can be decompressed independently for partial error recovery or for random access. This also inserts an extra empty block to flag independent blocks by prefacing each with the nine-byte sequence (in hex): 00 00 FF FF 00 00 00 FF FF.
Decompression can’t be parallelized, at least not without specially prepared deflate streams for that purpose. Asaresult, pigz uses a single thread (the main thread) for decompression, but will create three other threads for reading, writing, and check calculation, which can speed up decompression under some circumstances. Parallel decompression can be turned off by specifying one process ( -dp 1 or -tp 1 ).
All options on the command line are processed before any names are processed. If no names are provided on the command line, or if “-” is given as a name (but not after “–”), then the input is taken from stdin. If the GZIP or PIGZ environment var iables are set, then options are taken from their values before any command line options are processed, first from GZIP, then from PIGZ.
Compressed files can be restored to their original for m using pigz -d or unpigz.
OPTIONS -# --fast --best Regulate the speed of compression using the specified digit #, where −1 or −−fast indicates the fastest compression method (less compression) and −9 or −−best indicates the slowest compression method (best compression). -0 is no compression. −11 gives a few percent better compression at a severe cost in execution time, using the zopfli algorithm by Jyr ki Alakuijala. The default is −6.
-A --alias xxx Use xxx as the name for any --zip entry from stdin (the default name is “-”).
-b --blocksiz e mmm Set compression block size to mmmK (default 128KiB).
-c --stdout --to-stdout Wr ite all processed output to stdout (won’t delete).
-C --comment ccc Include the provided comment in the gzip header or zip central file header.
-d --decompress --uncompress Decompress the compressed input.
-f --force Force overwr ite, compress .gz, links, and to terminal.
-h --help Displayahelp screen and quit.
-H --huffman Compress using the Huffman-only strategy.
-i --independent Compress blocks independently for damage recovery.
-k --keep Do not delete original file after processing.
-K --zip Compress to PKWare zip (.zip) single entry for mat.
-l --list List the contents of the compressed input. -L --license Display the pigz license and quit.
-m --no-time Do not store or restore the modification time. -Nm will store or restore the name, but not the modification time. Note that the order of the options is important.
-M --time Store or restore the modification time. -nM will store or restore the modification time, but not the name. Note that the order of the options is important.
-n --no-name Do not store or restore the file name or the modification time. This is the default when decompressing. When the file name is not restored from the header, the name of the compressed file with the suffix stripped is the name of the decompressed file. When the modification time is not restored from the header, the modification time of the compressed file is used (not the current time).
-N --name Store or restore both the file name and the modification time. This is the default when compressing.
-p --processes n Allow up to n processes (default is the number of online processors)
-q --quiet --silent Pr int no messages, even on error.
-r --recursive Process the contents of all subdirectories.
-R --rsyncable Input-deter mined block locations for rsync.
-S --suffix .sss Use suffix .sss instead of .gz (for compression).
-t --test Test the integrity of the compressed input.
-U --rle Compress using the run length encoding strategy.
-v --verbose Provide more verbose output.
-V --version Show the version of pigz. -vV also shows the zlib version.
-z --zlib Compress to zlib (.zz) instead of gzip for mat.
– All arguments after “–” are treated as file names (for names that start with “-”) These options are unique to the -11 compression level:
-F --first Do iterations first, before block split (default is last).
-I, --iterations n Number of iterations for optimization (default 15).
-J, --maxsplits n Maximum number of split blocks (default 15).
-O --oneblock Do not split into smaller blocks (default is block splitting).
Install sudo apt install pigz 2.source is here Demos pigz [options] [files …] -0 to -9, -11 : 压缩级别 -p n : 指定压缩核心数,默认8个 -k :压缩后保留原文件
1 个回复
nccloud
pigz, unpigz
It means that “A parallel implementation of gzip for modern multi-processor, multi-core machines”
pigz, which stands for parallel implementation of gzip, is a fully functional replacement for gzip that exploits multiple processors and multiple cores to the hilt when compressing data. pigz was written by Mark Adler, and uses the zlib and pthread libraries.
Manual
SYNOPSIS
pigz [ −cdfhikKlLmMnNqrRtz0…9,11 ] [ -b blocksize ] [ -p threads ] [ -S suffix ] [ name … ]
unpigz [ −cfhikKlLmMnNqrRtz ] [ -b blocksize ] [ -p threads ] [ -S suffix ] [ name … ]
DESCRIPTION
Pigz compresses using threads to make use of multiple processors and cores. The input is broken up into 128 KB chunks with each compressed in parallel. The individual check value for eachchunk is also calculated in parallel. The compressed data is written in order to the output, and acombined check value is calculated from the individual check values.
The compressed data for mat generated is in the gzip, zlib, or single-entr y zip for mat using the deflate compression method. The compression produces partial raw deflate streams which are concatenated byasingle write thread and wrapped with the appropriate header and trailer, where the trailer contains the combined check value.
Each partial raw deflate stream is terminated by an empty stored block (using the Z_SYNC_FLUSH option of zlib), in order to end that partial bit stream at a byte boundary. That allows the partial streams to be concatenated simply as sequences of bytes. This adds a ver y
small four to five byte overhead to the output for each input chunk.
The default input block size is 128K, but can be changed with the -b option. The number of compress threads is set by default to the number of online processors, which can be changed using the -p option. Specifying -p 1 avoids the use of threads entirely.
The input blocks, while compressed independently, have the last 32K of the previous block loaded as a preset dictionary to preser ve the compression effectiveness of deflating in a single thread.This can be turned off using the -i or --independent option, so that the blocks can be decompressed independently for partial error recovery or for random access. This also inserts an extra empty block to flag independent blocks by prefacing each with the nine-byte sequence (in hex): 00 00 FF FF 00 00 00 FF FF.
Decompression can’t be parallelized, at least not without specially prepared deflate streams for that purpose. Asaresult, pigz uses a single thread (the main thread) for decompression, but will create three other threads for reading, writing, and check calculation, which can speed up decompression under some circumstances. Parallel decompression can be turned off by specifying one process ( -dp 1 or -tp 1 ).
All options on the command line are processed before any names are processed. If no names are provided on the command line, or if “-” is given as a name (but not after “–”), then the input is taken from stdin. If the GZIP or PIGZ environment var iables are set, then options are taken from their values before any command line options are processed, first from GZIP, then from PIGZ.
Compressed files can be restored to their original for m using pigz -d or unpigz.
OPTIONS
-# --fast --best
Regulate the speed of compression using the specified digit #, where −1 or −−fast indicates the fastest compression method (less compression) and −9 or −−best indicates the
slowest compression method (best compression). -0 is no compression. −11 gives a few
percent better compression at a severe cost in execution time, using the zopfli algorithm
by Jyr ki Alakuijala. The default is −6.
-A --alias xxx
Use xxx as the name for any --zip entry from stdin (the default name is “-”).
-b --blocksiz e mmm
Set compression block size to mmmK (default 128KiB).
-c --stdout --to-stdout
Wr ite all processed output to stdout (won’t delete).
-C --comment ccc
Include the provided comment in the gzip header or zip central file header.
-d --decompress --uncompress
Decompress the compressed input.
-f --force
Force overwr ite, compress .gz, links, and to terminal.
-h --help
Displayahelp screen and quit.
-H --huffman
Compress using the Huffman-only strategy.
-i --independent
Compress blocks independently for damage recovery.
-k --keep
Do not delete original file after processing.
-K --zip
Compress to PKWare zip (.zip) single entry for mat.
-l --list List the contents of the compressed input.
-L --license
Display the pigz license and quit.
-m --no-time
Do not store or restore the modification time. -Nm will store or restore the name, but not
the modification time. Note that the order of the options is important.
-M --time
Store or restore the modification time. -nM will store or restore the modification time, but
not the name. Note that the order of the options is important.
-n --no-name
Do not store or restore the file name or the modification time. This is the default when
decompressing. When the file name is not restored from the header, the name of the
compressed file with the suffix stripped is the name of the decompressed file. When the
modification time is not restored from the header, the modification time of the compressed file is used (not the current time).
-N --name
Store or restore both the file name and the modification time. This is the default when
compressing.
-p --processes n
Allow up to n processes (default is the number of online processors)
-q --quiet --silent
Pr int no messages, even on error.
-r --recursive
Process the contents of all subdirectories.
-R --rsyncable
Input-deter mined block locations for rsync.
-S --suffix .sss
Use suffix .sss instead of .gz (for compression).
-t --test
Test the integrity of the compressed input.
-U --rle
Compress using the run length encoding strategy.
-v --verbose
Provide more verbose output.
-V --version
Show the version of pigz. -vV also shows the zlib version.
-z --zlib
Compress to zlib (.zz) instead of gzip for mat.
–
All arguments after “–” are treated as file names (for names that start with “-”)
These options are unique to the -11 compression level:
-F --first
Do iterations first, before block split (default is last).
-I, --iterations n
Number of iterations for optimization (default 15).
-J, --maxsplits n
Maximum number of split blocks (default 15).
-O --oneblock
Do not split into smaller blocks (default is block splitting).
Install
sudo apt install pigz
2.source is here
Demos
pigz [options] [files …]
-0 to -9, -11 : 压缩级别
-p n : 指定压缩核心数,默认8个
-k :压缩后保留原文件
压缩文件,压缩后生成 filename.gz文件
pigz -9 -k filename #使用cpu 的所有核数进行压缩
pigz -6 -p 10 -k filename
pigz -5 -k -p 40 src.tar
tar cvf - test/ | pigz -9 -p 40 -f > test.tar.gz
tar cf - test/ | pigz -9 -f > test.tar.gz
sudo sh -c ‘tar cvf - test/ | pigz -9 -f >test.tar.gz’
解压文件
gzip -d filename.gz
ungzip filename.gz
pigz -d filename.gz
unpigz filename.gz