gzipの--rsyncableについて調べた
とある事情で gzip --rsyncable オプションを確認した話
gzip --rsyncableとは
gzip のオプションとして指定できる。ヘルプにはrsync friendly と記載がある。
何ができるのか
gzipでの圧縮ファイルをrsyncで転送する場合に、差分転送が速くなるらしい詳細は下記のブログが参考になる
https://beeznest.com/blog/2005/02/03/rsyncable-gzip/
先に検証結果
事前に250MBのファイル転送後、同一ファイル名で50MBを追加し2回目の転送した場合を比較した結果rsyncable | n回目 | rsync転送量(byte) | rsync転送時間 |
---|---|---|---|
× | 1回目(250MB) | 256073489 | 66.04 |
× | 2回目(300MB) | 176329187 | 49.26 |
○ | 1回目(250MB) | 256348182 | 70.29 |
○ | 2回目(300MB) | 51361684 | 21.75 |
- およそ2.5倍の速度差がある。
- rsyncableオプション無しでもそれなりの差分転送が行われている。
検証(ローカル→リモート)
環境
CentOS 7.4gzip 1.5
検証内容
- 250MB程度のtar + gzipファイルを作成
- リモートサーバにrsync転送
- 同名で50MBのファイルを追加しtar + gzipファイルを作成
- リモートサーバにrsync転送(1)
ddでファイル作成
50MB のファイルを5個作成$ mkdir rsyncable-no
$ cd rsyncable-no
$ for i in `seq 0 4`
do
dd if=/dev/urandom of=urandom-50MB-$i.dat count=1000 bs=50K
done
$ cd ..
$ cp -pr rsyncable-no rsyncable-yes
rsyncable 無し
初回転送$ time tar -c rsyncable-no | gzip > rsyncable-no.tar.gz
tar -c rsyncable-no 0.01s user 0.62s system 7% cpu 8.448 total
gzip > rsyncable-no.tar.gz 5.58s user 2.33s system 93% cpu 8.448 total
$ ls -l rsyncable-no.tar.gz
-rw-rw-r-- 1 hoge hoge 256042126 3月 22 00:39 rsyncable-no.tar.gz
$ time rsync -avv rsyncable-no.tar.gz 10.1.1.1:/tmp/
sending incremental file list
delta-transmission enabled
rsyncable-no.tar.gz
total: matches=0 hash_hits=0 false_alarms=0 data=256042126
sent 256073489 bytes received 31 bytes 3850729.62 bytes/sec
total size is 256042126 speedup is 1.00
rsync -avv rsyncable-no.tar.gz 10.1.1.1:/tmp/ 0.90s user 3.61s system 6% cpu 1:06.04 total
1分強かかった。2回目(ファイルを増やす)
$ cd rsyncable-no
$ dd if=/dev/urandom of=urandom-50MB-a.dat count=1000 bs=50K
$ cd ..
$ time tar -c rsyncable-no | gzip > rsyncable-no.tar.gz
tar -c rsyncable-no 0.01s user 0.81s system 8% cpu 9.915 total
gzip > rsyncable-no.tar.gz 6.73s user 2.58s system 93% cpu 9.916 total
$ ls -l rsyncable-no.tar.gz
-rw-rw-r-- 1 hoge hoge 307250844 3月 22 00:42 rsyncable-no.tar.gz
$ time rsync -avv rsyncable-no.tar.gz 10.1.1.1:/tmp/
sending incremental file list
delta-transmission enabled
rsyncable-no.tar.gz
total: matches=8187 hash_hits=38131086 false_alarms=1296 data=176258844
sent 176329187 bytes received 112052 bytes 3564469.47 bytes/sec
total size is 307250844 speedup is 1.74
rsync -avv rsyncable-no.tar.gz 10.1.1.1:/tmp/ 3.37s user 4.59s system 16% cpu 49.261 total
2回目は50MB増えたが50秒程度で完了すでに差分転送されているように見える…?
rsyncable 有り
初回転送$ time tar -c rsyncable-yes | gzip --rsyncable > rsyncable-yes.tar.gz
tar -c rsyncable-yes 0.01s user 0.69s system 6% cpu 10.614 total
gzip --rsyncable > rsyncable-yes.tar.gz 7.56s user 2.82s system 96% cpu 10.788 total
$ ls -l rsyncable-yes.tar.gz
-rw-rw-r-- 1 hoge hoge 256316782 3月 22 00:47 rsyncable-yes.tar.gz
$ time rsync -av rsyncable-yes.tar.gz 10.1.1.1:/tmp/
sending incremental file list
delta-transmission enabled
rsyncable-yes.tar.gz
total: matches=0 hash_hits=0 false_alarms=0 data=256316782
sent 256348182 bytes received 31 bytes 3636144.87 bytes/sec
total size is 256316782 speedup is 1.00
rsync -avv rsyncable-yes.tar.gz 10.255.32.161:/tmp/ 0.91s user 3.50s system 6% cpu 1:10.29 total
2回目(ファイルを増やす)
$ cd rsyncable-yes
$ dd if=/dev/urandom of=urandom1MB-a.dat count=1024 bs=10K
$ cd ..
$ time tar -c rsyncable-yes | gzip --rsyncable > rsyncable-yes.tar.gz
tar -c rsyncable-yes 0.01s user 0.94s system 7% cpu 12.904 total
gzip --rsyncable > rsyncable-yes.tar.gz 9.31s user 3.09s system 96% cpu 12.905 total
$ ls -l rsyncable-yes.tar.gz
-rw-rw-r-- 1 hoge hoge 307579352 3月 22 01:20 rsyncable-yes.tar.gz
$ time rsync -av rsyncable-yes.tar.gz 10.1.1.1:/tmp/
sending incremental file list
delta-transmission enabled
rsyncable-yes.tar.gz
total: matches=16010 hash_hits=11125851 false_alarms=402 data=51291272
sent 51361684 bytes received 112115 bytes 2287724.40 bytes/sec
total size is 307579352 speedup is 5.98
rsync -avv rsyncable-yes.tar.gz 10.255.32.161:/tmp/ 1.76s user 1.22s system 13% cpu 21.754 total
検証(ローカル→ローカル)
環境
CentOS 7.4, gzip 1.5検証内容
ddでファイル作成
1GB のファイルを10個作成$ mkdir rsyncable-no
$ cd rsyncable-no
$ for i in $(seq 0 9)
do
dd if=/dev/urandom of=urandom1GB-$i.dat count=1000 bs=1024K
done
$ cd ..
$ cp -pr rsyncable-no rsyncable-yes
rsyncable 無しで試験
初回転送$ tar -c rsyncable-no | gzip > rsyncable-no.tar.gz
$ ls -l rsyncable-no.tar.gz
-rw-rw-r-- 1 hoge hoge 104875894 3月 21 21:42 rsyncable-no.tar.gz
$ time rsync -av rsyncable-no.tar.gz /tmp/
sending incremental file list
rsyncable-no.tar.gz
sent 104888805 bytes received 31 bytes 69925890.67 bytes/sec
total size is 104875894 speedup is 1.00
rsync -av rsyncable-no.tar.gz /tmp/ 0.09s user 1.08s system 113% cpu 1.029 total
2回目(ファイルを増やす)$ cd rsyncable-no
$ dd if=/dev/urandom of=urandom1MB-a.dat count=1024 bs=10K
$ ls -l rsyncable-no.tar.gz
-rw-rw-r-- 1 hoge hoge 115363409 3月 21 21:45 rsyncable-no.tar.gz
$ cd ..
$ $ tar -c rsyncable-no | gzip --rsyncable > rsyncable-no.tar.gz
$ time rsync -av rsyncable-no.tar.gz /tmp/
sending incremental file list
rsyncable-no.tar.gz
sent 115377600 bytes received 31 bytes 76918420.67 bytes/sec
total size is 115363409 speedup is 1.00
rsync -av rsyncable-no.tar.gz /tmp/ 0.11s user 1.10s system 114% cpu 1.051 total
1回目と2回目で特に大きな違いは無し。rsyncable 有りで試験
初回転送$ tar -c rsyncable-yes | gzip --rsyncable > rsyncable-yes.tar.gz
$ ls -l rsyncable-yes.tar.gz
-rw-rw-r-- 1 hoge hoge 104988183 3月 21 21:47 rsyncable-yes.tar.gz
$ time rsync -av rsyncable-yes.tar.gz /tmp/
sending incremental file list
rsyncable-yes.tar.gz
sent 105001107 bytes received 31 bytes 70000758.67 bytes/sec
total size is 104988183 speedup is 1.00
rsync -av rsyncable-yes.tar.gz /tmp/ 0.07s user 1.01s system 113% cpu 0.957 total
2回目(ファイルを増やす)
$ cd rsyncable-yes
$ dd if=/dev/urandom of=urandom1MB-a.dat count=1024 bs=10K
$ cd ..
$ tar -c rsyncable-yes | gzip --rsyncable > rsyncable-yes.tar.gz
$ ls -l rsyncable-yes.tar.gz
-rw-rw-r-- 1 hoge hoge 115487047 3月 21 21:50 rsyncable-yes.tar.gz
$ time rsync -av rsyncable-yes.tar.gz /tmp/
sending incremental file list
rsyncable-yes.tar.gz
sent 115501255 bytes received 31 bytes 77000857.33 bytes/sec
total size is 115487047 speedup is 1.00
rsync -av rsyncable-yes.tar.gz /tmp/ 0.09s user 1.13s system 113% cpu 1.072 total
ローカルでは差分転送が行われないため–rsyncableオプションも効果は無い
コメント
コメントを投稿