]> git.pld-linux.org Git - packages/djbdns.git/blame - djbdns-cachestats.patch
tinydns-log: add sample to log only fatals and startup messages
[packages/djbdns.git] / djbdns-cachestats.patch
CommitLineData
a453401c
MW
1#
2# This patch to djbdns 1.05 modifies the dnscache program to keep a
3# counter of cache hits and cache misses.
4#
5# Two new fields are added to the ``stats'' output line:
6# . the fifth number is the number of cache hits
7# . the sixth number is the number of cache misses
8# e.g.
9# @400000003fa92ccc317d70f4 stats 3 1201 1 0 21 49
10# indicates 21 hits and 49 misses.
11#
12# James Raftery <james@now.ie> 6 Nov. 2003
13#
14--- djbdns-1.05.orig/cache.c Sun Feb 11 21:11:45 2001
15+++ djbdns-1.05/cache.c Wed Nov 5 17:21:06 2003
16@@ -7,6 +7,11 @@
17
18 uint64 cache_motion = 0;
19
20+/* record cache stats */
21+/* James Raftery <james@now.ie> 6 Nov. 2003 */
22+uint64 cache_hit = 0;
23+uint64 cache_miss = 0;
24+
25 static char *x = 0;
26 static uint32 size;
27 static uint32 hsize;
28@@ -112,15 +117,20 @@
29 if (u > size - pos - 20 - keylen) cache_impossible();
30 *datalen = u;
31
32+ cache_hit++;
33 return x + pos + 20 + keylen;
34 }
35 }
36 nextpos = prevpos ^ get4(pos);
37 prevpos = pos;
38 pos = nextpos;
39- if (++loop > 100) return 0; /* to protect against hash flooding */
40+ if (++loop > 100) { /* to protect against hash flooding */
41+ cache_miss++;
42+ return 0;
43+ }
44 }
45
46+ cache_miss++;
47 return 0;
48 }
49
50--- djbdns-1.05.orig/cache.h Sun Feb 11 21:11:45 2001
51+++ djbdns-1.05/cache.h Wed Nov 5 17:13:36 2003
52@@ -5,6 +5,12 @@
53 #include "uint64.h"
54
55 extern uint64 cache_motion;
56+
57+/* record cache stats */
58+/* James Raftery <james@now.ie> 6 Nov. 2003 */
59+extern uint64 cache_hit;
60+extern uint64 cache_miss;
61+
62 extern int cache_init(unsigned int);
63 extern void cache_set(const char *,unsigned int,const char *,unsigned int,uint32);
64 extern char *cache_get(const char *,unsigned int,unsigned int *,uint32 *);
65--- djbdns-1.05.orig/log.c Sun Feb 11 21:11:45 2001
66+++ djbdns-1.05/log.c Wed Nov 5 17:21:12 2003
67@@ -276,6 +276,12 @@
68 {
69 extern uint64 numqueries;
70 extern uint64 cache_motion;
71+
72+ /* record cache stats */
73+ /* James Raftery <james@now.ie> 6 Nov. 2003 */
74+ extern uint64 cache_hit;
75+ extern uint64 cache_miss;
76+
77 extern int uactive;
78 extern int tactive;
79
80@@ -283,6 +289,8 @@
81 number(numqueries); space();
82 number(cache_motion); space();
83 number(uactive); space();
84- number(tactive);
85+ number(tactive); space();
86+ number(cache_hit); space();
87+ number(cache_miss);
88 line();
89 }
This page took 0.036521 seconds and 4 git commands to generate.