From c8c47fa11235e9d4f4faddd8b11efd27145b72a8 Mon Sep 17 00:00:00 2001 From: Andrew Perepechko Date: Tue, 3 Jun 2014 20:47:00 +0400 Subject: [PATCH] LU-3496 ost: lprocfs batch update Update lprocfs stats such as cache hits, misses, totals using single calls to lprocfs_counter_add so as to improve performance. Non-zero number of hits/misses/totals for a single RPC counts as a single sample for the respective hits/misses/totals counter. Signed-off-by: Andrew Perepechko Reviewed-by: Alexander Boyko Reviewed-by: alexander_zarochentsev@xyratex.com Reviewed-by: Vitaly Fertman Xyratex-bug-id: MRP-999 Change-Id: I8771e81b7e0356436a1ffcb7e9c51b87580750a9 Reviewed-on: http://review.whamcloud.com/6756 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- lustre/osd-ldiskfs/osd_io.c | 28 ++++++++++++++++++---------- lustre/tests/sanity.sh | 6 +++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index bbdf111..8e23a21 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1148,7 +1148,7 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt, struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt)); struct timeval start, end; unsigned long timediff; - int rc = 0, i, m = 0, cache = 0; + int rc = 0, i, m = 0, cache = 0, cache_hits = 0, cache_misses = 0; LASSERT(inode); @@ -1176,15 +1176,13 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt, lnb[i].rc = lnb[i].len; m += lnb[i].len; - lprocfs_counter_add(osd->od_stats, LPROC_OSD_CACHE_ACCESS, 1); - if (PageUptodate(lnb[i].page)) { - lprocfs_counter_add(osd->od_stats, - LPROC_OSD_CACHE_HIT, 1); - } else { - lprocfs_counter_add(osd->od_stats, - LPROC_OSD_CACHE_MISS, 1); - osd_iobuf_add_page(iobuf, lnb[i].page); - } + if (PageUptodate(lnb[i].page)) { + cache_hits++; + } else { + cache_misses++; + osd_iobuf_add_page(iobuf, lnb[i].page); + } + if (cache == 0) generic_error_remove_page(inode->i_mapping,lnb[i].page); } @@ -1192,6 +1190,16 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt, timediff = cfs_timeval_sub(&end, &start, NULL); lprocfs_counter_add(osd->od_stats, LPROC_OSD_GET_PAGE, timediff); + if (cache_hits != 0) + lprocfs_counter_add(osd->od_stats, LPROC_OSD_CACHE_HIT, + cache_hits); + if (cache_misses != 0) + lprocfs_counter_add(osd->od_stats, LPROC_OSD_CACHE_MISS, + cache_misses); + if (cache_hits + cache_misses != 0) + lprocfs_counter_add(osd->od_stats, LPROC_OSD_CACHE_ACCESS, + cache_hits + cache_misses); + if (iobuf->dr_npages) { rc = osd_ldiskfs_map_inode_pages(inode, iobuf->dr_pages, iobuf->dr_npages, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 55547c1..95452ee 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9281,14 +9281,14 @@ function roc_hit_init() { dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null idx=$(printf %04x $i) BEFORE=$(get_osd_param $list *OST*$idx stats | - awk '$1 == "cache_access" {sum += $2} + awk '$1 == "cache_access" {sum += $7} END { printf("%0.0f", sum) }') cancel_lru_locks osc cat $file >/dev/null AFTER=$(get_osd_param $list *OST*$idx stats | - awk '$1 == "cache_access" {sum += $2} + awk '$1 == "cache_access" {sum += $7} END { printf("%0.0f", sum) }') echo BEFORE:$BEFORE AFTER:$AFTER @@ -9305,7 +9305,7 @@ function roc_hit_init() { function roc_hit() { local list=$(comma_list $(osts_nodes)) echo $(get_osd_param $list '' stats | - awk '$1 == "cache_hit" {sum += $2} + awk '$1 == "cache_hit" {sum += $7} END { printf("%0.0f", sum) }') } -- 1.8.3.1