Whamcloud - gitweb
LU-3496 ost: lprocfs batch update 56/6756/9
authorAndrew Perepechko <andrew_perepechko@xyratex.com>
Tue, 3 Jun 2014 16:47:00 +0000 (20:47 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 16 Jun 2014 03:50:20 +0000 (03:50 +0000)
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 <andrew_perepechko@xyratex.com>
Reviewed-by: Alexander Boyko <Alexander_Boyko@xyratex.com>
Reviewed-by: alexander_zarochentsev@xyratex.com
Reviewed-by: Vitaly Fertman <Vitaly_Fertman@xyratex.com>
Xyratex-bug-id: MRP-999
Change-Id: I8771e81b7e0356436a1ffcb7e9c51b87580750a9
Reviewed-on: http://review.whamcloud.com/6756
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/osd-ldiskfs/osd_io.c
lustre/tests/sanity.sh

index bbdf111..8e23a21 100644 (file)
@@ -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,
index 55547c1..95452ee 100644 (file)
@@ -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) }')
 }