public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Jake Maul <jakemaul@gmail.com>
To: systemtap@sourceware.org
Subject: Linux VFS cache hit rate script
Date: Wed, 20 Apr 2011 19:04:00 -0000	[thread overview]
Message-ID: <BANLkTi=yYfLEU5N61mZZkXLoYV_ttWc6kQ@mail.gmail.com> (raw)

[-- 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"

             reply	other threads:[~2011-04-20 19:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-20 19:04 Jake Maul [this message]
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

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='BANLkTi=yYfLEU5N61mZZkXLoYV_ttWc6kQ@mail.gmail.com' \
    --to=jakemaul@gmail.com \
    --cc=systemtap@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).