#!/usr/sbin/dtrace -qs /* * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. * * cache.d - Display DB cache activity * * usage: cache.d { -p | -c " [= warmup/ { misses++; @misses[/*arg1 == 0 ? "" : */copyinstr(arg1)] = count(); } /* mpool-hit(unsigned hits, char *file, unsigned pgno) */ bdb$target:::mpool-hit /tick >= warmup/ { hits++; @hits[arg1 == 0 ? "" : copyinstr(arg1)] = count(); } /* mpool-evict(char *file, unsigned pgno, BH *buf */ bdb$target:::mpool-evict /tick >= warmup/ { evictions++; @evictions[arg0 == 0 ? "" : copyinstr(arg0)] = count(); } profile:::tick-1sec { tick++; secs--; } /* * Print a banner when starting the measurement period. */ profile:::tick-1sec /tick == warmup/ { printf("Cache info: %8s %8s %8s starting @ %Y\n", "hits", "misses", "evictions", walltimestamp); secs = interval; } profile:::tick-1sec /secs == 0 && tick >= warmup/ { printf(" %6d %8d %8d %8d\n", tick, hits, misses, evictions); hits = misses = evictions = 0; printa("Hits for %20s %@u\n", @hits); printa("Misses for %20s %@u\n", @misses); printa("Evictions for %20s %@u\n", @evictions); trunc(@hits); trunc(@misses); trunc(@evictions); secs = interval; } profile:::tick-1sec /tick == maxtick/ { exit(0); } dtrace:::END { printf("\n"); printa("Hits for %20s %@u\n", @hits); printa("Misses for %20s %@u\n", @misses); printa("Evictions for %20s %@u\n", @evictions); }