summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-10-08 06:21:02 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-09 00:48:23 -0700
commit78da899c5ceac63c424ad3d9e712b6a26abae7ba (patch)
tree325bff0b16178f8cae10298dc0ea6501bb194b36 /xlators
parentb9bfc46a9a26c356bd79a453c6daa77692f0a624 (diff)
performance/stat-prefetch: Add accounting of cache hits and misses.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 221 (stat prefetch implementation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=221
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c15
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index 1056d29e272..0adfded8d87 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.c
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c
@@ -597,6 +597,10 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
wind:
if (lookup_behind) {
+ if (cache) {
+ cache->hits++;
+ }
+
wind_frame = copy_frame (frame);
if (wind_frame == NULL) {
op_ret = -1;
@@ -618,6 +622,10 @@ wind:
STACK_WIND (wind_frame, sp_lookup_behind_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->lookup, loc, xattr_req);
} else {
+ if (cache) {
+ cache->miss++;
+ }
+
STACK_WIND (frame, sp_lookup_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->lookup, loc, xattr_req);
@@ -1728,10 +1736,17 @@ sp_release (xlator_t *this, fd_t *fd)
sp_fd_ctx_t *fd_ctx = NULL;
uint64_t value = 0;
int32_t ret = 0;
+ sp_cache_t *cache = NULL;
ret = fd_ctx_del (fd, this, &value);
if (!ret) {
fd_ctx = (void *)(long) value;
+ cache = fd_ctx->cache;
+ if (cache) {
+ gf_log (this->name, GF_LOG_DEBUG, "cache hits: %lu, "
+ "cache miss: %lu", cache->hits, cache->miss);
+ }
+
sp_fd_ctx_free (fd_ctx);
}
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.h b/xlators/performance/stat-prefetch/src/stat-prefetch.h
index 20b5e4a6fea..dd6b067c5bd 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.h
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.h
@@ -37,6 +37,8 @@ struct sp_cache {
* happen.
*/
gf_lock_t lock;
+ unsigned long miss;
+ unsigned long hits;
};
typedef struct sp_cache sp_cache_t;