1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#!/usr/sbin/dtrace -qs
/*
* Copyright (c) 2012, 2015 Oracle and/or its affiliates. All rights reserved.
*
* cache.d - Display DB cache activity
*
* usage: cache.d { -p <pid> | -c "<program> [<args]" } \
* [interval=1#seconds)] [iterations=60] [delay #seconds]
*
* For each 'interval' seconds display overall and per-file cache stats:
* hits
* misses
* evictions
* Empty lines are displayed when nothing happened for that file & counter
* during that interval.
*
* The delay parameter delays the start of sampling until that many
* seconds have passed.
*
* Static probes used:
* mpool-miss(unsigned misses, char *file, unsigned pgno)
* mpool-hit(unsigned hits, char *file, unsigned pgno)
* mpool-evict(char *file, unsigned pgno, BH *buf)
*/
#pragma D option defaultargs
dtrace:::BEGIN
{
interval = $1 != 0 ? $1 : 10;
maxtick = $2 != 0 ? $2 : 60;
warmup = $3 != 0 ? $3 : 0;
hits = misses = evictions = 0;
secs = interval;
tick = 0;
}
/* mpool-miss(unsigned misses, char *file, unsigned pgno)
*/
bdb$target:::mpool-miss
/tick >= warmup/
{
misses++;
@misses[/*arg1 == 0 ? "<null!>" : */copyinstr(arg1)] = count();
}
/* mpool-hit(unsigned hits, char *file, unsigned pgno) */
bdb$target:::mpool-hit
/tick >= warmup/
{
hits++;
@hits[arg1 == 0 ? "<null!>" : copyinstr(arg1)] = count();
}
/* mpool-evict(char *file, unsigned pgno, BH *buf */
bdb$target:::mpool-evict
/tick >= warmup/
{
evictions++;
@evictions[arg0 == 0 ? "<null!>" : 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);
}
|