mharsch / arcstat

uses Perl to extract, format, and display kstats from the ZFS ARC
67 stars 31 forks source link

100 percent hit% sometimes appears as 1.0K #6

Closed mharsch closed 12 years ago

mharsch commented 12 years ago

$ ./arcstat.pl -f read,hits,miss,hit%,l2read,l2hits,l2miss,l2hit%,arcsz,l2size 6 read hits miss hit% l2read l2hits l2miss l2hit% arcsz l2size 0 0 0 0 0 0 0 0 29G 0 441 441 0 100 0 0 0 0 29G 0 205 205 0 100 0 0 0 0 29G 0 434 434 0 100 0 0 0 0 29G 0 141 141 0 100 0 0 0 0 29G 0 491 491 0 100 0 0 0 0 29G 0 446 446 0 100 0 0 0 0 29G 0 201 201 0 99 0 0 0 0 29G 0 481 481 0 100 0 0 0 0 29G 0 220 220 0 100 0 0 0 0 29G 0 644 644 0 100 0 0 0 0 29G 0 480 480 0 100 0 0 0 0 29G 0 219 218 0 99 0 0 0 0 29G 0 452 452 0 100 0 0 0 0 29G 0 174 174 0 1.0K 0 0 0 0 29G 0 <<<<<<<<<<<<<<<<< WTF? 478 478 0 100 0 0 0 0 29G 0 483 483 0 100 0 0 0 0 29G 0

mharsch commented 12 years ago

We're making it into the scaling loop inside prettynum because the calculated value for hit% is slightly larger than 100. This can be proved by adding some debug code inside prettynum to print out the $num and $scale values when the condition is met that $num is greater than $scale (thus triggering the scaling loop):

./arcstat.pl -f hit% 6 hit% 0 99 100 100 100 100 num is 100.00000000000001421085 scale is 100.00000000000000000000 1.0K

mharsch commented 12 years ago

force order of operations with parenthesis. Fixed.