public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Linux VFS cache hit rate script
@ 2011-04-20 19:04 Jake Maul
  2011-04-20 20:09 ` William Cohen
  0 siblings, 1 reply; 17+ messages in thread
From: Jake Maul @ 2011-04-20 19:04 UTC (permalink / raw)
  To: systemtap

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

Greetings all,

I have recently put a script up on the War Stories page, and it was
requested of me to also post it to the list, along with a .meta file.
They're both attached.

http://sourceware.org/systemtap/wiki/WSCacheHitRate

Let me know what you think! It's my first SystemTap script, so I'm
sure there are improvements that could be made. I'm by no means a
kernel hacker, or even a C dev... just a lowly sysadmin. :)

Thanks,
Jake

[-- Attachment #2: cache-hit-rate.stp --]
[-- Type: application/octet-stream, Size: 780 bytes --]

global cache_bytes, disk_bytes, counter

probe vfs.read.return {
  if (bytes_read>0) {
    if (devname=="N/A") { /* N/A means cache hit... right? */
      cache_bytes += bytes_read
    } else {
      disk_bytes += bytes_read
    }
  }
}

# print VFS hits and misses every 5 second, plus the hit rate in %
probe timer.s(5) {
    if (counter%15 == 0) {
        printf ("\n%18s %18s %10s %10s\n", "Cache Reads (KB)", "Disk Reads (KB)", "Miss Rate", "Hit Rate")
    }
    counter++
    hitrate =  10000 * cache_bytes / (cache_bytes+disk_bytes)
    missrate = 10000 * disk_bytes / (cache_bytes+disk_bytes)
    printf ("%18d %18d %6d.%02d%% %6d.%02d%%\n", cache_bytes/1024, disk_bytes/1024, missrate/100, missrate%100, hitrate/100, hitrate%100)
    cache_bytes = 0
    disk_bytes = 0
}

[-- Attachment #3: cache-hit-rate.meta --]
[-- Type: application/octet-stream, Size: 536 bytes --]

title: VFS Cache Hit Rate
name: cache-hit-rate.stp
version: 1.0
author: Jake Maul
keywords: io profiling vfs cache
subsystem: io
status: production
exit: user-controlled
output: timed interval (vmstat-like)
scope: system-wide
description:  The cache-hit-rate.stp script checks the bytes_read and devname fields of vfs.read.return, and uses them to determine how much data was read directly from disk vs how much was read from the Linux VFS cache.
test_check: stap -p4 cache-hit-rate.stp
test_installcheck: stap iostats.stp -c "sleep 6"

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-04-26  2:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 19:04 Linux VFS cache hit rate script Jake Maul
2011-04-20 20:09 ` William Cohen
2011-04-20 20:46   ` Jake Maul
2011-04-20 20:57     ` Josh Stone
2011-04-20 22:25       ` Jake Maul
2011-04-21 20:17   ` Jake Maul
2011-04-21 22:31     ` William Cohen
2011-04-21 23:02       ` Jake Maul
2011-04-21 23:46         ` Josh Stone
2011-04-22 19:17           ` Jake Maul
2011-04-22 20:28             ` Josh Stone
2011-04-22 21:47               ` Jake Maul
2011-04-25 21:54                 ` Josh Stone
2011-04-26  2:11                   ` Jake Maul
2011-04-25 22:53           ` Josh Stone
2011-04-26  1:59             ` Jake Maul
2011-04-26  2:44               ` Josh Stone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).