From: Kevin Constantine <Kevin.Constantine-FfNkGbSheRGpB8w63BLUukEOCMrvLtNR@public.gmane.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/2] nfs-iostat.py: Print Data Cache Statistics
Date: Tue, 21 Apr 2009 10:54:04 -0700 [thread overview]
Message-ID: <49EE083C.6010105@disney.com> (raw)
In-Reply-To: <4EEE5CE8-9A51-4828-8B70-B48A35F46F01@oracle.com>
Chuck Lever wrote:
> On Apr 20, 2009, at 10:03 PM, Kevin Constantine wrote:
>> add --data flag to print data cache statistics
>> print read cache stats from __print_data_cache_stats
>
> It's been a while since I wrote this code... comments below.
>
>> Signed-off-by: Kevin Constantine <kevin.constantine-FfNkGbSheRGpB8w63BLUukEOCMrvLtNR@public.gmane.org>
>> ---
>> tools/nfs-iostat/nfs-iostat.py | 26 ++++++++++++++++++++------
>> 1 files changed, 20 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/nfs-iostat/nfs-iostat.py
>> b/tools/nfs-iostat/nfs-iostat.py
>> index 9626d42..d331a72 100644
>> --- a/tools/nfs-iostat/nfs-iostat.py
>> +++ b/tools/nfs-iostat/nfs-iostat.py
>> @@ -220,14 +220,20 @@ class DeviceData:
>> """Print the data cache hit rate
>> """
>> nfs_stats = self.__nfs_data
>> - app_bytes_read = float(nfs_stats['normalreadbytes'])
>> + app_bytes_read = float(nfs_stats['normalreadbytes'] +
>> nfs_stats['directreadbytes'])
>> if app_bytes_read != 0:
>> - client_bytes_read = float(nfs_stats['serverreadbytes'] -
>> nfs_stats['directreadbytes'])
>> - ratio = ((app_bytes_read - client_bytes_read) * 100) /
>> app_bytes_read
>> -
>> + read_bytes_from_server = float(nfs_stats['serverreadbytes'])
>> + directio_bytes_from_server =
>> float(nfs_stats['directreadbytes'])
>> + standard_read_bytes_from_server = read_bytes_from_server
>> - directio_bytes_from_server
>> + cached_read_bytes = float(app_bytes_read -
>> read_bytes_from_server)
>
> I'm not sure why you are reversing the sense of this computation.
> "directreadbytes" is the count of bytes that applications read with
> O_DIRECT. These are never cached, but they are counted in
> "serverreadbytes", so my logic subtracts them before computing the hit
> ratio. Was there some accounting problem you found? (If there was,
> it's worth stating that explicitly in the patch description).
Originally you had app_bytes_read = normalreadbytes, but that's not entirely true, since an app might be reading with
O_DIRECT, therefore app_bytes_read should probably be normal + direct.
client_bytes_read seemed ambiguous to me, is that bytes being read by the host client from the server, bytes being read
by the nfs client process? read_bytes_from_server seemed more logical, but in the diff block below, I've removed that
altogether, and am just left with cached_read_bytes.
>
>> + ratio = (cached_read_bytes / app_bytes_read) * 100
>
> The other functions use (x * 100) / y -- I seem to recall there are
> rounding errors if you do it the way you've done it here, but I don't
> remember exactly what the issue was. But you are changing this one so
> it is different than the all the other similar computations. Can you
> state your reason?
>
since cached_read_bytes = app_bytes_read - client_bytes_read, i used (cached_read_bytes / app_bytes_read) * 100, but
that is the same as (cached_read_bytes * 100) / app_bytes_read if you'd rather see that.
new diff block below (if it all checks out, i'll send the whole patch, unless you'd rather just see that.)
diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py
index 9626d42..7dae659 100644
--- a/tools/nfs-iostat/nfs-iostat.py
+++ b/tools/nfs-iostat/nfs-iostat.py
@@ -220,14 +220,17 @@ class DeviceData:
"""Print the data cache hit rate
"""
nfs_stats = self.__nfs_data
- app_bytes_read = float(nfs_stats['normalreadbytes'])
+ app_bytes_read = float(nfs_stats['normalreadbytes'] + nfs_stats['directreadbytes'])
if app_bytes_read != 0:
- client_bytes_read = float(nfs_stats['serverreadbytes'] - nfs_stats['directreadbytes'])
- ratio = ((app_bytes_read - client_bytes_read) * 100) / app_bytes_read
-
+ cached_read_bytes = float(app_bytes_read - float(nfs_stats['serverreadbytes']))
+ ratio = (cached_read_bytes * 100) / app_bytes_read
print
- print 'app bytes: %f client bytes %f' % (app_bytes_read, client_bytes_read)
- print 'Data cache hit ratio: %4.2f%%' % ratio
+ print '%10s %15s %15s %15s %7s' % ("Data Read:", "From Server", "From Cache", "Total", "Hit %")
+ print '%10s %13.4fMB %13.4fMB %13.4fMB %6.2f%%' % ("", \
+ float(nfs_stats['serverreadbytes']) / 1024.0 / 1024.0, \
+ cached_read_bytes / 1024.0 / 1024.0, \
+ app_bytes_read / 1024.0 / 1024.0, \
+ ratio)
def __print_attr_cache_stats(self, sample_time):
"""Print attribute cache efficiency stats
-kevin
> --
> Chuck Lever
> chuck[dot]lever[at]oracle[dot]com
next prev parent reply other threads:[~2009-04-21 17:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-21 2:03 Add data cache statistics to nfs-iostat.py Kevin Constantine
[not found] ` <1240279414-30528-1-git-send-email-kevin.constantine-FfNkGbSheRGpB8w63BLUukEOCMrvLtNR@public.gmane.org>
2009-04-21 2:03 ` [PATCH 1/2] nfs-iostat.py: Print Data Cache Statistics Kevin Constantine
[not found] ` <1240279414-30528-2-git-send-email-kevin.constantine-FfNkGbSheRGpB8w63BLUukEOCMrvLtNR@public.gmane.org>
2009-04-21 2:03 ` [PATCH 2/2] nfs-iostat.py: Added bytes written output Kevin Constantine
[not found] ` <1240279414-30528-3-git-send-email-kevin.constantine-FfNkGbSheRGpB8w63BLUukEOCMrvLtNR@public.gmane.org>
2009-04-21 14:26 ` Chuck Lever
2009-04-21 17:57 ` Kevin Constantine
[not found] ` <49EE0901.2040704-P5ys19MLBK/QT0dZR+AlfA@public.gmane.org>
2009-04-21 19:00 ` Chuck Lever
2009-04-21 20:39 ` Kevin Constantine
2009-04-21 20:46 ` Chuck Lever
2009-04-21 14:26 ` [PATCH 1/2] nfs-iostat.py: Print Data Cache Statistics Chuck Lever
2009-04-21 17:54 ` Kevin Constantine [this message]
[not found] ` <49EE083C.6010105-P5ys19MLBK/QT0dZR+AlfA@public.gmane.org>
2009-04-21 18:58 ` Chuck Lever
2009-04-22 1:42 ` [PATCH] " Kevin Constantine
[not found] ` <1240364531-11499-1-git-send-email-kevin.constantine-FfNkGbSheRGpB8w63BLUukEOCMrvLtNR@public.gmane.org>
2009-04-22 18:38 ` Chuck Lever
2009-04-25 3:16 ` Kevin Constantine
[not found] ` <49F28096.9060300-P5ys19MLBK/QT0dZR+AlfA@public.gmane.org>
2009-04-27 15:33 ` Chuck Lever
2009-04-30 1:57 ` Kevin Constantine
2009-04-30 14:43 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49EE083C.6010105@disney.com \
--to=kevin.constantine-ffnkgbshergpb8w63bluukeocmrvltnr@public.gmane.org \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox