系統技術非業餘研究 » 推介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 by wp-posturl plugin for wordpress.
No related posts.