SNAPPY,ZLIB,LZ4,gzip几个压缩算法的对比

以下是各种压缩方式下,应用服务器的性能数据

 

场景                                响应时间         QPS       CPU         网络带宽(out)    GC数目

 

====================================================================

 

压缩:无               |          21.6ms         11500      81            118m                      0            

 

压缩:SNAPPY     |          28ms            9900        77            111m                     19

 

压缩:ZLIB           |          25ms            10000      78            112m                     27

 

压缩:LZ4            |          23ms            10900      78            110m                     0

 

压缩:gzip            |          30ms            9900        78            113m                     44

 

下面是用本地机器做的对比:

 

deflater,gzip,lz4,snappy各项对比如下:

 

压缩比:

 

source byte size:      2974090

 

snappy byte size:     499280

 

gzip byte size:          383723

 

deflater byte size:    463823

 

lz4 byte size:           170805

 

性能比:

name  Mode  Cnt  Score Error  Units
deflater thrpt 20 ≈ 10^-4   ops/us
gzip thrpt 20 ≈ 10^-5   ops/us
lz4 thrpt 20 ≈ 10^-3   ops/us
snappy thrpt 20 ≈ 10^-4   ops/us
deflater avgt 20  30595.443 ± 3117.520   us/op
gzip avgt 20  79238.541 ± 7208.015   us/op
lz4 avgt 20 3149.854 ± 395.372   us/op
snappy avgt 20  11257.427 ± 1219.347   us/op
deflater sample 431  47889.938 ± 826.705   us/op
deflater:deflater·p0.00 sample   36700.16   us/op
deflater:deflater·p0.50 sample   46989.312   us/op
deflater:deflater·p0.90 sample   53202.125   us/op
deflater:deflater·p0.95 sample   55351.706   us/op
deflater:deflater·p0.99 sample   68073.554   us/op
deflater:deflater·p0.999 sample   81788.928   us/op
deflater:deflater·p0.9999 sample   81788.928   us/op
deflater:deflater·p1.00 sample   81788.928   us/op
gzip sample 222 93336.844 ± 1869.349   us/op
gzip:gzip·p0.00 sample   72089.6   us/op
gzip:gzip·p0.50 sample   94044.16   us/op
gzip:gzip·p0.90 sample   100545.331   us/op
gzip:gzip·p0.95 sample   107026.842   us/op
gzip:gzip·p0.99 sample   118761.718   us/op
gzip:gzip·p0.999 sample   128450.56   us/op
gzip:gzip·p0.9999 sample   128450.56   us/op
gzip:gzip·p1.00 sample   128450.56   us/op
lz4 sample 5419 3866.797 ± 54.781   us/op
lz4:lz4·p0.00 sample   2082.816   us/op
lz4:lz4·p0.50 sample   4009.984   us/op
lz4:lz4·p0.90 sample   4530.176   us/op
lz4:lz4·p0.95 sample   4980.736   us/op
lz4:lz4·p0.99 sample   6859.981   us/op
lz4:lz4·p0.999 sample   22632.202   us/op
lz4:lz4·p0.9999 sample   32178.176   us/op
lz4:lz4·p1.00 sample   32178.176   us/op
snappy sample 1775 11473.738 ± 189.907   us/op
snappy:snappy·p0.00 sample   6299.648   us/op
snappy:snappy·p0.50 sample   11665.408   us/op
snappy:snappy·p0.90 sample   12900.762   us/op
snappy:snappy·p0.95 sample   14139.392   us/op
snappy:snappy·p0.99 sample   17627.873   us/op
snappy:snappy·p0.999 sample   56448.516   us/op
snappy:snappy·p0.9999 sample   59703.296   us/op
snappy:snappy·p1.00 sample   59703.296   us/op
deflater ss 20 49073.148 ± 4697.407   us/op
gzip ss 20 108874.516 ± 9298.844   us/op
lz4 ss 20 7779.001 ± 4453.597   us/op
snappy ss 20 11424.403 ± 2107.730   us/op

注:

 

Mode标注:

 

thrpt:Throughput: operations per unit of time.                

 

(Runs by continuously calling methods, counting the total throughput over all worker threads. This mode is time-based, and it will run until the iteration time expires.)

 

avgt:Average time: average time per per operation.      

 

(Runs by continuously calling methods, counting the average time to call over all worker threads. This is the inverse of , but with different aggregation policy. This mode is time-based, and it will run until the iteration time expires.)

 

sample:Sample time: samples the time for each operation.

 

(Runs by continuously calling methods, and randomly samples the time needed for the call. This mode automatically adjusts the sampling frequency, but may omit some pauses which missed the sampling measurement. This mode is time-based, and it will run until the iteration time expires.)

 

ss:Single shot time: measures the time for a single operation.

 

(Runs by calling once and measuring its time. This mode is useful to estimate the "cold" performance when you don't want to hide the warmup invocations, or if you want to see the progress from call to call, or you want to record every single sample. This mode is work-based, and will run only for a single invocation of method.)

 

注意:lz4使用的是LZ4Factory.fastestJavaInstance().fastCompressor(),如果用fastestInstance而不是fastestJavaInstance的时候也会使用Native通过JNI实现

 

          deflater使用的是Deflater(Deflater.BEST_SPEED)模式

 

lz4在压缩比上完胜

 

lz4在首次初始化速度上完胜,

 

lz4在速度上完胜

 

lz4在稳定性上完胜

 

但是lz4的解压比较麻烦,需要指定原byte数组大小,所以开发起来工作量要大些,但是它性能好压缩比高啊。

你可能感兴趣的:(java)