xz 圧縮マルチスレッド失敗 -> pbzip2 で圧縮

最近NptePC のバックアップを取っていなかったので、~ 以下をbackup

$ cd ~/..
$ find ./mk -print |grep -v \.iso$ | grep -v \.img$ | xargs tar cv - | xz -9 > /mnt/mk20100716.tar.xz

xz にしたらなかなか進みません。CPU 1つしか使ってないのでこれ2つ使えないかなーとman 見ると、

-T threads, --threads=threads
Specify the maximum number of worker threads to use. The default is the number of available CPU cores. You can see the current value of threads near the end of the output of
the --long-help option.

The actual number of worker threads can be less than threads if using more threads would exceed the memory usage limit. In addition to CPU-intensive worker threads, xz may
use a few auxiliary threads, which don't use a lot of CPU time.

これはいけると-T 2 とか4 とかしてみたんですがCPU 使用率は変わらず。よくよく見ると其の下に、

Multithreaded compression and decompression are not implemented yet, so this option has no effect for now.

未だ実装されてないっぽいですよorz
find の指定先を複数に分けて同時に複数アーカイブするとかしないとダメっぽいですね。

若しくはbzip2 ならマルチCPU な実装あったはずだから圧縮率犠牲にしてそっちか。HDD 安くなってるからこっちの方がいいかも…。

- Parallel BZIP2 (PBZIP2)
http://compression.ca/pbzip2/

ということで、

$ find ./mk -print |grep -v \.iso$ | grep -v \.img$ | xargs tar cv - | pbzip2 -p2 -9 -c > /mnt/mk20100716.tar.bz2

$ vmstat 1 2
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
4 0 105172 34520 63432 1830296 1 5 449 141 830 1620 57 12 26 6
2 1 105172 33580 63520 1826796 0 0 2316 0 1268 3251 86 15 0 0
$ top -p 23818 -b
top - 03:46:16 up 3:10, 4 users, load average: 4.02, 3.93, 3.06
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 90.2%us, 9.5%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.3%hi, 0.0%si, 0.0%st
Mem: 3961288k total, 3892052k used, 69236k free, 68740k buffers
Swap: 3903752k total, 105048k used, 3798704k free, 1918100k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23818 root 20 0 108m 21m 980 S 153 0.6 11:43.21 pbzip2

CPU 使い切ってるようです。ファンの音酷いですけどね

追記)
このコマンドだとスペース入りのファイルとか失敗するかな?GNU filnd の-print0 とxargs -0 を入れたほうがよさげ。