Date: Wed, 17 Feb 2010 03:27:36 -0600 From: Scot Hetzel <swhetzel@gmail.com> To: jhell <jhell@dataix.net>, Bartosz Stec <bartosz.stec@it4pro.pl> Cc: freebsd-stable@freebsd.org Subject: Re: ZFS tuning [was: hardware for home use large storage] Message-ID: <790a9fff1002170127s153a6813p5e92055dc5d94ba2@mail.gmail.com> In-Reply-To: <4B7BAF59.7040407@it4pro.pl> References: <cf9b1ee01002150049o43fced71ucb5776a0a1eaf4cf@mail.gmail.com> <alpine.BSF.2.00.1002152024040.74553@pragry.qngnvk.ybpny> <4B7AD0A3.9080701@barryp.org> <20100216175946.GA98082@icarus.home.lan> <20100216200511.GA95812@server.vk2pj.dyndns.org> <20100216215637.GA4299@icarus.home.lan> <alpine.BSF.2.00.1002170241080.14189@pragry.qngnvk.ybpny> <4B7BA6A5.9020306@it4pro.pl> <20100217093237.fe4b4e14.torfinn.ingolfsen@broadpark.no> <4B7BAF59.7040407@it4pro.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Wed, Feb 17, 2010 at 2:56 AM, Bartosz Stec <bartosz.stec@it4pro.pl> wrote:
> On 2010-02-17 09:32, Torfinn Ingolfsen wrote:
>>
>> On Wed, 17 Feb 2010 09:19:49 +0100
>> Bartosz Stec<bartosz.stec@it4pro.pl> wrote:
>>
>>
>>>
>>> So here's my reply (last line seems most interesting ;) :
>>>
>>
>> [...snipped...]
>>
>>>
>>> Illegal division by zero at ./arc_summary.pl line 242.
>>>
>>
>> FWIW, I also got this line when I ran this script on my idle zfs server.
>>
>
> I'm not a PERL programmer (or programmer at all ;), but what I see is script
> doesn't check if L2ARC is used at all, so it will always try compute these
> lines:
>
> printf("\tL2 Hit Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_hits / ( $l2_hits +
> $l2_misses )), $l2_hits );
> printf("\tL2 Miss Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_misses / (
> $l2_hits + $l2_misses )), $l2_misses );
> printf("\tL2 Feeds Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_feeds / (
> $l2_hits + $l2_misses )), $l2_feeds );
>
> Without active L2ARC it will always generate divide at zeo error, so it
> seems that additional check for usable L2ARC values is needed at first
> place.
>
The attached patch fixes the divide by zero errors.
Scot
[-- Attachment #2 --]
--- arc_summary.pl-orig 2010-02-17 07:30:49.000000000 +0000
+++ arc_summary.pl 2010-02-17 03:10:31.808960635 +0000
@@ -210,6 +210,7 @@
#### L2 ARC Stats Sysctl's #############
my $l2_hits = ${Kstat}->{zfs}->{0}->{arcstats}->{l2_hits}; # used
my $l2_misses = ${Kstat}->{zfs}->{0}->{arcstats}->{l2_misses}; # used
+my $l2_hits_misses = $l2_hits + $l2_misses; # used
my $l2_feeds = ${Kstat}->{zfs}->{0}->{arcstats}->{l2_feeds}; # used
my $l2_rw_clash = ${Kstat}->{zfs}->{0}->{arcstats}->{l2_rw_clash};
my $l2_writes_sent = ${Kstat}->{zfs}->{0}->{arcstats}->{l2_writes_sent}; # used
@@ -238,18 +239,38 @@
print "\n";
print "L2 ARC Breakdown:\n";
-printf("\tL2 Access Total:\t\t\t%d\n", ( $l2_hits + $l2_misses ) );
-printf("\tL2 Hit Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_hits / ( $l2_hits + $l2_misses )), $l2_hits );
-printf("\tL2 Miss Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_misses / ( $l2_hits + $l2_misses )), $l2_misses );
-printf("\tL2 Feeds Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_feeds / ( $l2_hits + $l2_misses )), $l2_feeds );
+printf("\tL2 Access Total:\t\t\t%d\n", ( $l2_hits_misses ) );
+if ( $l2_hits_misses > 0) {
+ printf("\tL2 Hit Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_hits / ( $l2_hits_misses )), $l2_hits );
+ printf("\tL2 Miss Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_misses / ( $l2_hits_misses )), $l2_misses );
+ printf("\tL2 Feeds Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_feeds / ( $l2_hits_misses )), $l2_feeds );
+} else {
+ printf("\tL2 Hit Ratio:\t\t\tUnknown\t%d\n", $l2_hits );
+ printf("\tL2 Miss Ratio:\t\t\tUnknown\t%d\n", $l2_misses );
+ printf("\tL2 Feeds Ratio:\t\t\tUnknown\t%d\n", $l2_feeds );
+}
print "\n";
-printf( "\tL2 Reads:\t\t\t%0.2f%%\t%d\n", 100 * (( $l2_hits + $l2_misses - $l2_writes_sent ) / ( $l2_hits + $l2_misses )), ( $l2_hits + $l2_misses - $l2_writes_sent ));
+if ( $l2_hits_misses > 0) {
+ printf( "\tL2 Reads:\t\t\t%0.2f%%\t%d\n", 100 * (( $l2_hits_misses - $l2_writes_sent ) / ( $l2_hits_misses )), ( $l2_hits_misses - $l2_writes_sent ));
+} else {
+ printf( "\tL2 Reads:\t\t\tUnknown\t%d\n", ( $l2_hits_misses - $l2_writes_sent ));
+}
print "\n";
+
print "\tL2 Writes:\n";
-printf("\t Sent Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_writes_sent / ($l2_hits + $l2_misses)), $l2_writes_sent );
-printf("\t Done Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_writes_done / $l2_writes_sent ), $l2_writes_done );
-printf("\t Error Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_writes_error / $l2_writes_sent ), $l2_writes_error );
+if ( $l2_hits_misses > 0) {
+ printf("\t Sent Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_writes_sent / ($l2_hits_misses)), $l2_writes_sent );
+} else {
+ printf("\t Sent Ratio:\t\t\tUnknown\t%d\n", $l2_writes_sent );
+}
+if ( $l2_writes_sent > 0) {
+ printf("\t Done Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_writes_done / $l2_writes_sent ), $l2_writes_done );
+ printf("\t Error Ratio:\t\t\t%0.2f%%\t%d\n", 100 * ( $l2_writes_error / $l2_writes_sent ), $l2_writes_error );
+} else {
+ printf("\t Done Ratio:\t\t\tUnknown\t%d\n", $l2_writes_done );
+ printf("\t Error Ratio:\t\t\tUnknown\t%d\n", $l2_writes_error );
+}
print "\n\n";
#### Tunables #####################
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff1002170127s153a6813p5e92055dc5d94ba2>
