2009-04-15 20:30:07

by Kevin Constantine

[permalink] [raw]
Subject: Exposing cache statistics

Has there been any effort to expose caching statistics to the end user?
On the client-side, it would be useful to see how much data is being
re-used from cache vs data that gets retrieved over the wire. Similarly
on the server side, it would be nice to see how much data is being
served from cache vs having to pull the data from disk.

Just wondering if anyone started anything to expose this sort of
information.

Thanks
-kevin


2009-04-17 15:58:26

by Chuck Lever

[permalink] [raw]
Subject: Re: Exposing cache statistics


On Apr 16, 2009, at 8:33 PM, Kevin Constantine wrote:

> Trond Myklebust wrote:
>> On Wed, 2009-04-15 at 13:30 -0700, Kevin Constantine wrote:
>>> Has there been any effort to expose caching statistics to the end
>>> user? On the client-side, it would be useful to see how much
>>> data is being re-used from cache vs data that gets retrieved over
>>> the wire. Similarly on the server side, it would be nice to see
>>> how much data is being served from cache vs having to pull the
>>> data from disk.
>>>
>>> Just wondering if anyone started anything to expose this sort of
>>> information.
>> See the nfs-iostat tool in the nfs-utils package:
>> http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=tree;f=tools/nfs-iostat;h=929e303cc762a68dfd01546f5150eb294274164e;hb=refs/heads/master
>> Note that you need a 2.6.17 kernel or newer.
>> Cheers
>> Trond
>
> Thanks Trond-
>
> It seems like nfs-iostat is displaying the number of pages that are
> being written to the read/write caches (i'm only looking at the
> client-side at the moment), and what I'm interested in is the ratio
> of pages being read from cache vs data being fetched from the server.
>
> Is there any documentation on the layout of /proc/self/mountstats?


Take a look at the python code in nfs-iostat or mountstats. Besides
documenting the layout of /proc/self/mountstats, there may also be
some code in there that shows how to compute cache hit ratios.

The __print_data_cache_stats function in nfs-iostat does just this for
the page cache, but I don't see it called anywhere.

Note these scripts are not finished, which is why they are currently
not installed by default.

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com

2009-04-15 20:41:36

by Trond Myklebust

[permalink] [raw]
Subject: Re: Exposing cache statistics

On Wed, 2009-04-15 at 13:30 -0700, Kevin Constantine wrote:
> Has there been any effort to expose caching statistics to the end user?
> On the client-side, it would be useful to see how much data is being
> re-used from cache vs data that gets retrieved over the wire. Similarly
> on the server side, it would be nice to see how much data is being
> served from cache vs having to pull the data from disk.
>
> Just wondering if anyone started anything to expose this sort of
> information.

See the nfs-iostat tool in the nfs-utils package:

http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=tree;f=tools/nfs-iostat;h=929e303cc762a68dfd01546f5150eb294274164e;hb=refs/heads/master

Note that you need a 2.6.17 kernel or newer.

Cheers
Trond


2009-04-17 00:33:03

by Kevin Constantine

[permalink] [raw]
Subject: Re: Exposing cache statistics

Trond Myklebust wrote:
> On Wed, 2009-04-15 at 13:30 -0700, Kevin Constantine wrote:
>> Has there been any effort to expose caching statistics to the end user?
>> On the client-side, it would be useful to see how much data is being
>> re-used from cache vs data that gets retrieved over the wire. Similarly
>> on the server side, it would be nice to see how much data is being
>> served from cache vs having to pull the data from disk.
>>
>> Just wondering if anyone started anything to expose this sort of
>> information.
>
> See the nfs-iostat tool in the nfs-utils package:
>
> http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=tree;f=tools/nfs-iostat;h=929e303cc762a68dfd01546f5150eb294274164e;hb=refs/heads/master
>
> Note that you need a 2.6.17 kernel or newer.
>
> Cheers
> Trond

Thanks Trond-

It seems like nfs-iostat is displaying the number of pages that are
being written to the read/write caches (i'm only looking at the
client-side at the moment), and what I'm interested in is the ratio of
pages being read from cache vs data being fetched from the server.

Is there any documentation on the layout of /proc/self/mountstats?

-kevin

2009-04-17 11:08:48

by Steve Dickson

[permalink] [raw]
Subject: Re: Exposing cache statistics



Kevin Constantine wrote:
> Trond Myklebust wrote:
>> On Wed, 2009-04-15 at 13:30 -0700, Kevin Constantine wrote:
>>> Has there been any effort to expose caching statistics to the end
>>> user? On the client-side, it would be useful to see how much data
>>> is being re-used from cache vs data that gets retrieved over the
>>> wire. Similarly on the server side, it would be nice to see how much
>>> data is being served from cache vs having to pull the data from disk.
>>>
>>> Just wondering if anyone started anything to expose this sort of
>>> information.
>>
>> See the nfs-iostat tool in the nfs-utils package:
>>
>>
>> http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=tree;f=tools/nfs-iostat;h=929e303cc762a68dfd01546f5150eb294274164e;hb=refs/heads/master
>>
>>
>> Note that you need a 2.6.17 kernel or newer.
>>
>> Cheers
>> Trond
>
> Thanks Trond-
>
> It seems like nfs-iostat is displaying the number of pages that are
> being written to the read/write caches (i'm only looking at the
> client-side at the moment), and what I'm interested in is the ratio of
> pages being read from cache vs data being fetched from the server.
>
> Is there any documentation on the layout of /proc/self/mountstats?
No, unfortunately not...

steved.

2009-04-17 12:55:06

by Trond Myklebust

[permalink] [raw]
Subject: Re: Exposing cache statistics

On Fri, 2009-04-17 at 07:05 -0400, Steve Dickson wrote:
>
> Kevin Constantine wrote:
> > Trond Myklebust wrote:
> >> On Wed, 2009-04-15 at 13:30 -0700, Kevin Constantine wrote:
> >>> Has there been any effort to expose caching statistics to the end
> >>> user? On the client-side, it would be useful to see how much data
> >>> is being re-used from cache vs data that gets retrieved over the
> >>> wire. Similarly on the server side, it would be nice to see how much
> >>> data is being served from cache vs having to pull the data from disk.
> >>>
> >>> Just wondering if anyone started anything to expose this sort of
> >>> information.
> >>
> >> See the nfs-iostat tool in the nfs-utils package:
> >>
> >>
> >> http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=tree;f=tools/nfs-iostat;h=929e303cc762a68dfd01546f5150eb294274164e;hb=refs/heads/master
> >>
> >>
> >> Note that you need a 2.6.17 kernel or newer.
> >>
> >> Cheers
> >> Trond
> >
> > Thanks Trond-
> >
> > It seems like nfs-iostat is displaying the number of pages that are
> > being written to the read/write caches (i'm only looking at the
> > client-side at the moment), and what I'm interested in is the ratio of
> > pages being read from cache vs data being fetched from the server.
> >
> > Is there any documentation on the layout of /proc/self/mountstats?
> No, unfortunately not...

I'd suggest using the python code in nfs-iostat as a reference.

You should be able to figure out how much data is being read on the wire
by looking at nfs_stats['serverreadbytes']. Comparing that to the value
in nfs_stats['normalreadbytes'] (which tells you the total number of
bytes requested in read() calls) should give you a rough estimate for
how much data is being read from cache.

Cheers
Trond