Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add some basic statistics to pool_cache.
details: https://anonhg.NetBSD.org/src/rev/c32aff48149a
branches: trunk
changeset: 500378:c32aff48149a
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Dec 11 05:22:55 2000 +0000
description:
Add some basic statistics to pool_cache.
diffstat:
sys/kern/subr_pool.c | 18 +++++++++++++++++-
sys/sys/pool.h | 10 +++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diffs (105 lines):
diff -r 4163cfb122ba -r c32aff48149a sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c Mon Dec 11 04:56:01 2000 +0000
+++ b/sys/kern/subr_pool.c Mon Dec 11 05:22:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_pool.c,v 1.47 2000/12/10 17:03:34 thorpej Exp $ */
+/* $NetBSD: subr_pool.c,v 1.48 2000/12/11 05:22:56 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -1455,6 +1455,8 @@
pc = TAILQ_NEXT(pc, pc_poollist)) {
(*pr)("\tcache %p: allocfrom %p freeto %p\n", pc,
pc->pc_allocfrom, pc->pc_freeto);
+ (*pr)("\t hits %lu misses %lu ngroups %lu nitems %lu\n",
+ pc->pc_hits, pc->pc_misses, pc->pc_ngroups, pc->pc_nitems);
for (pcg = TAILQ_FIRST(&pc->pc_grouplist); pcg != NULL;
pcg = TAILQ_NEXT(pcg, pcg_list)) {
(*pr)("\t\tgroup %p: avail %d\n", pcg, pcg->pcg_avail);
@@ -1557,6 +1559,13 @@
pc->pc_dtor = dtor;
pc->pc_arg = arg;
+ pc->pc_hits = 0;
+ pc->pc_misses = 0;
+
+ pc->pc_ngroups = 0;
+
+ pc->pc_nitems = 0;
+
simple_lock(&pp->pr_slock);
TAILQ_INSERT_TAIL(&pp->pr_cachelist, pc, pc_poollist);
simple_unlock(&pp->pr_slock);
@@ -1638,6 +1647,7 @@
* the caller. We will allocate a group, if necessary,
* when the object is freed back to the cache.
*/
+ pc->pc_misses++;
simple_unlock(&pc->pc_slock);
object = pool_get(pc->pc_pool, flags);
if (object != NULL && pc->pc_ctor != NULL) {
@@ -1650,6 +1660,8 @@
}
have_group:
+ pc->pc_hits++;
+ pc->pc_nitems--;
object = pcg_get(pcg);
if (pcg->pcg_avail == 0)
@@ -1690,6 +1702,7 @@
if (pcg != NULL) {
memset(pcg, 0, sizeof(*pcg));
simple_lock(&pc->pc_slock);
+ pc->pc_ngroups++;
TAILQ_INSERT_TAIL(&pc->pc_grouplist, pcg, pcg_list);
if (pc->pc_freeto == NULL)
pc->pc_freeto = pcg;
@@ -1707,6 +1720,7 @@
}
have_group:
+ pc->pc_nitems++;
pcg_put(pcg, object);
if (pcg->pcg_avail == PCG_NOBJECTS)
@@ -1732,6 +1746,7 @@
pcg = npcg) {
npcg = TAILQ_NEXT(pcg, pcg_list);
while (pcg->pcg_avail != 0) {
+ pc->pc_nitems--;
object = pcg_get(pcg);
if (pcg->pcg_avail == 0 && pc->pc_allocfrom == pcg)
pc->pc_allocfrom = NULL;
@@ -1740,6 +1755,7 @@
(*putit)(pc->pc_pool, object, __FILE__, __LINE__);
}
if (free_groups) {
+ pc->pc_ngroups--;
TAILQ_REMOVE(&pc->pc_grouplist, pcg, pcg_list);
if (pc->pc_freeto == pcg)
pc->pc_freeto = NULL;
diff -r 4163cfb122ba -r c32aff48149a sys/sys/pool.h
--- a/sys/sys/pool.h Mon Dec 11 04:56:01 2000 +0000
+++ b/sys/sys/pool.h Mon Dec 11 05:22:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pool.h,v 1.19 2000/12/07 05:45:57 thorpej Exp $ */
+/* $NetBSD: pool.h,v 1.20 2000/12/11 05:22:55 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -68,6 +68,14 @@
int (*pc_ctor)(void *, void *, int);
void (*pc_dtor)(void *, void *);
void *pc_arg;
+
+ /* Statistics. */
+ unsigned long pc_hits; /* cache hits */
+ unsigned long pc_misses; /* cache misses */
+
+ unsigned long pc_ngroups; /* # cache groups */
+
+ unsigned long pc_nitems; /* # objects currently in cache */
};
struct pool {
Home |
Main Index |
Thread Index |
Old Index