原创文章,转载请说明: 转载自Erlang非专业研讨
本文链接地点: 推介xz高紧缩率算法
这几天看到Linux内核2.6.38公布的release申明内里提到:
The version .38 kernel comes with a library for decompressing
XZ, a format developed from LZMA and known for its high levels of
compression. This library is the basis not only for SquashFS, which
now also offers XZ, but also for code that allows the kernel to
unpack any parts of itself and of the initial ram disks (initrds)
that were compressed with XZ.
感觉比力猎奇, Linux下有那末多的压缩算法, 为何要用这个, 它有甚么过人的地方? 本日深切领会了下xz,
趁便作了简略的benchmark体验了下.
官方网站在这里
#我的机械设置装备摆设
$ summary
...
# Aspersa System Summary Report ##############################
Date | 2011-03-17 10:24:13 UTC (local TZ: CST +0800)
Hostname | yufeng-laptop
Uptime | 1:46, 5 users, load average: 0.97, 1.03, 0.84
System | Dell Inc.; Latitude E6400; vNot Specified (Portable)
Service Tag | 9MKDW2X
Release | Ubuntu 10.10
Kernel | 2.6.38-yufeng
Architecture | CPU = 64-bit, OS = 64-bit
Threading | NPTL 2.12.1
Compiler | GNU CC version 4.4.5.
SELinux | No SELinux detected
# Processor ##################################################
Processors | physical = 1, cores = 2, virtual = 2, hyperthreading = no
Speeds | 2x2535.000
Models | 2xIntel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz
Caches | 2x3072 KB
# Memory #####################################################
Total | 1.95G
Free | 16.70M
Used | physical = 1.93G, swap = 4.42M, virtual = 1.94G
Buffers | 51.30M
Caches | 1001.72M
Used | 1.09G
...
#装置压缩软件
$ apt-get install xz-utils bzip2 lzop
#筹办数据
$ tar cf 1.tar linux-2.6.38 && cp 1.tar 2.tar && cp 1.tar 3.tar
$ ll 1.tar 2.tar 3.tar
-rw-r--r-- 1 yufeng yufeng 440494080 2011-03-17 18:17 1.tar
-rw-r--r-- 1 yufeng yufeng 440494080 2011-03-17 18:17 2.tar
-rw-r--r-- 1 yufeng yufeng 440494080 2011-03-17 18:17 3.tar
#开压
$ time xz 1.tar
real 5m4.269s
user 5m1.670s
sys 0m1.340s
$ time bzip2 2.tar
real 1m3.357s
user 1m1.490s
sys 0m0.610s
$ time lzop 3.tar
real 0m5.526s
user 0m3.550s
sys 0m0.490s
#看压缩成果
$ ll 1.tar.xz 2.tar.bz2 3.tar.lzo
-rw-r--r-- 1 yufeng yufeng 65092368 2011-03-17 18:18 1.tar.xz
-rw-r--r-- 1 yufeng yufeng 76103454 2011-03-17 18:19 2.tar.bz2
-rw-r--r-- 1 yufeng yufeng 151462273 2011-03-17 18:17 3.tar.lzo
#解压复原
$ time xz -d 1.tar.xz
real 0m8.507s
user 0m6.390s
sys 0m0.670s
$ time bzip2 -d 2.tar.bz2
real 0m19.019s
user 0m17.420s
sys 0m0.670s
$ time lzop -d 3.tar.lzo
real 0m6.261s
user 0m1.610s
sys 0m0.610s
从下面的数据咱们能够看出,
xz的压缩率确切不错,解压速率也缓慢,便是压缩对照慢,可是我们大部门的需要是读,以是无所谓,一生压不了几回.
保举在名目中利用,Linux都用了,咱们怕啥!
玩的高兴!
PS.
刘晓东 同窗说:
方才在网上看到了一个XZ的并行版本pxz(http://jnovy.fedorapeople.org/pxz/),固然它的目标是为了加速xz的压缩速率同时尽可能小的改动xz本来的低压缩率。
Post Footer automatically generated bywp-posturl pluginfor
wordpress.
博文推荐: