summaryrefslogtreecommitdiff
path: root/src/journal/mmap-cache.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-26 18:58:44 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-26 18:58:44 +0100
commitbf807d4dbf27c783db8dfd7f4eca321ae4be5b00 (patch)
treebc8810a5a2b08cfb1c4ab3d9ea48646c280a3010 /src/journal/mmap-cache.c
parentb8e891e699e1336c5527f8203e4e8f67c9bbeb84 (diff)
journald: keep statistics on how of we hit/miss the mmap cache
Diffstat (limited to 'src/journal/mmap-cache.c')
-rw-r--r--src/journal/mmap-cache.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 6c9194a1a5..117dc2f3a5 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -72,6 +72,9 @@ struct MMapCache {
int n_ref;
unsigned n_windows;
+ unsigned n_hit, n_missed;
+
+
Hashmap *fds;
Hashmap *contexts;
@@ -542,13 +545,19 @@ int mmap_cache_get(
/* Check whether the current context is the right one already */
r = try_context(m, fd, prot, context, keep_always, offset, size, ret);
- if (r != 0)
+ if (r != 0) {
+ m->n_hit ++;
return r;
+ }
/* Search for a matching mmap */
r = find_mmap(m, fd, prot, context, keep_always, offset, size, ret);
- if (r != 0)
+ if (r != 0) {
+ m->n_hit ++;
return r;
+ }
+
+ m->n_missed++;
/* Create a new mmap */
return add_mmap(m, fd, prot, context, keep_always, offset, size, st, ret);
@@ -578,3 +587,15 @@ void mmap_cache_close_context(MMapCache *m, unsigned context) {
context_free(c);
}
+
+unsigned mmap_cache_get_hit(MMapCache *m) {
+ assert(m);
+
+ return m->n_hit;
+}
+
+unsigned mmap_cache_get_missed(MMapCache *m) {
+ assert(m);
+
+ return m->n_missed;
+}