Eric Kustarz's Weblog

e-street

All | FileBench | NFS | SETUP | ZFS

20080514 Wednesday May 14, 2008

 プールの冗長度を知る

6656655 zdb should be able to display blkptr signatures のフィードバックを受けて、プール内にあるブロックポインタの「シグニチャー」の参照が可能になりました。例として、まず空のプールにデータを入れてみましょう。

heavy# zpool create bigIO c0t0d0 c0t1d0
heavy# zpool list
NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
bigIO   928G  95.5K   928G     0%  ONLINE  -
heavy# mkfile 1m /bigIO/1m.txt
heavy# echo "dedup me" > /bigIO/ejk.txt
heavy# cp /bigIO/ejk.txt /bigIO/ejk2.txt
heavy# echo "no dedup" > /bigIO/nope.txt
heavy# cp /bigIO/ejk.txt /bigIO/ejk3.txt

新オプション「-S」を追加して zdb を実行しましょう。コマンドに「user:all」を渡します。「user」は zdb に (ユーザーデータとメタデータの両方ではなく) ユーザーデータブロックのみを表示させる指示で、「all」は zdb にすべてのデータブロックを表示させる指示です (チェックサムアルゴリズムの強度比較はスキップ) 。

heavy# zdb -L -S user:all bigIO
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       131072  1       ZFS plain file  fletcher2       uncompressed    0:0:0:0
0       512     1       ZFS plain file  fletcher2       uncompressed    656d207075646564:a:ada40e0eac8cac80:140
0       512     1       ZFS plain file  fletcher2       uncompressed    656d207075646564:a:ada40e0eac8cac80:140
0       512     1       ZFS plain file  fletcher2       uncompressed    7075646564206f6e:a:eac8cac840dedc0:140
0       512     1       ZFS plain file  fletcher2       uncompressed    656d207075646564:a:ada40e0eac8cac80:140
heavy# 

各ブロックポインタのシグニチャーが表示されます。横の段は、レベル、物理的容量、dva 数、オブジェクトタイプ、チェックサムタイプ、圧縮タイプ、ブロックの実体チェックサムです。

興味深い機能ですが、どのように活用すればよいでしょうか。たとえば、プールに対して dedup がどの程度効果を発揮するかを知ることができます。dedup が実体チェックサムを元にマッチを行なっており、すべてのチェックサムアルゴリズムが十分な強度である (実際には、sha256 以上の強度が必要) と仮定しましょう。先ほどのプールに簡単な perl スクリプト「line_by_line_process.pl」 (このブログの最後にソースコードを掲載) を適用することで、次のような情報が得られます。

heavy# zdb -L -S user:all bigIO > /tmp/zdb_out.txt
heavy# sort -k 7 -t "`/bin/echo '\t'`" /tmp/zdb_out.txt > /tmp/zdb_out_sorted.txt
heavy# ./line_by_line_process.pl /tmp/zdb_out_sorted.txt 
total PSIZE:0t1050624
total unique PSIZE:0t132096
total that can be duped:0t918528
percent that can be duped  87.4269005847953%
heavy#   

この例では、プールを 87% も dedup できることがわかります。もう少し詳細に調査すると、mkfile がゼロブロックをすべて書き出していることがわかります。圧縮を有効にしている場合、ファイルが使用する実際のブロックは表示されません。では「ejk.txt」の実データだけを dedup する例を見てみましょう。

heavy# zpool destroy bigIO
heavy# zpool create bigIO c0t0d0 c0t1d0
heavy# dd if=/dev/random of=/bigIO/1m.txt bs=1024 count=5
5+0 records in
5+0 records out
heavy# echo "dedup me" > /bigIO/ejk.txt
heavy# cp /bigIO/ejk.txt /bigIO/ejk2.txt
heavy# echo "no dedup" > /bigIO/nope.txt
heavy# cp /bigIO/ejk.txt /bigIO/ejk3.txt
heavy# zdb -L -S user:all bigIO > /tmp/zdb_out.txt
heavy# sort -k 7 -t "`/bin/echo '\t'`" /tmp/zdb_out.txt > /tmp/zdb_out_sorted.txt
heavy# ./line_by_line_process.pl /tmp/zdb_out_sorted.txt       
total PSIZE:0t7168
total unique PSIZE:0t6144
total that can be duped:0t1024
percent that can be duped  14.285714%
heavy# 

この手順による例では 14% までの容量を実際に dedup 可能であることがわかります。容量をかなり節約できるでしょう。

次の課題は、プールがどの程度 dedup 可能なのかということでです。




追記:次は perl スクリプト「line_by_line_process.pl」のソースコードです。

#!/usr/bin/perl

# Run this script as:
#  % script 


# total PSIZE
$totalps = 0;

# total unique PSIZE
$totalups = 0;

$last_cksum = -1;

$path = $ARGV[0];
open(FH, $path) or die "Can't open $!";

while (<>) {
my $line = $_;
($level, $psize, $ndvas, $type, $cksum_alg, $compress, $cksum) = split /\t/, $line, 7;
if ($cksum ne $last_cksum) {
$totalups += $psize;
        }
$last_cksum = $cksum;
$totalps += $psize;
}

print "total PSIZE:0t".$totalps."\n";
print "total unique PSIZE:0t".$totalups."\n";
print "total that can be duped:0t".($totalps - $totalups)."\n";
print "percent that can be duped  ".($totalps - $totalups) / $totalps * 100 ."%\n";


(2008-05-14 22:50:33.0/2008-05-14 20:00:00.0) Permalink Comments [0]
Trackback: http://blogs.sun.com/erickustarz/en_US/entry/%E3%83%97%E3%83%BC%E3%83%AB%E3%81%AE%E5%86%97%E9%95%B7%E5%BA%A6%E3%82%92%E7%9F%A5%E3%82%8B

Trackback URL: http://blogs.sun.com/erickustarz/en_US/entry/%E3%83%97%E3%83%BC%E3%83%AB%E3%81%AE%E5%86%97%E9%95%B7%E5%BA%A6%E3%82%92%E7%9F%A5%E3%82%8B
Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed

« July 2008
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today


XML





Today's Page Hits: 429