]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add latency statistics for a read/fsync operation 25648/head
authorWei Qiaomiao <wei.qiaomiao@zte.com.cn>
Wed, 19 Dec 2018 07:15:22 +0000 (15:15 +0800)
committerWei Qiaomiao <wei.qiaomiao@zte.com.cn>
Thu, 20 Dec 2018 11:10:23 +0000 (19:10 +0800)
Since read and fsync are citical operation in IO performance test, it is necessary to add lantency statistics for them.

Signed-off-by: Wei Qiaomiao <wei.qiaomiao@zte.com.cn>
src/client/Client.cc
src/client/Client.h

index 5836d92319623027fee142e9b0de309f967e81d7..241533ad2d7f8f2021744fb5fce31c58fadb2b4c 100644 (file)
@@ -498,6 +498,8 @@ void Client::_finish_init()
   plb.add_time_avg(l_c_reply, "reply", "Latency of receiving a reply on metadata request");
   plb.add_time_avg(l_c_lat, "lat", "Latency of processing a metadata request");
   plb.add_time_avg(l_c_wrlat, "wrlat", "Latency of a file data write operation");
+  plb.add_time_avg(l_c_read, "rdlat", "Latency of a file data read operation");
+  plb.add_time_avg(l_c_fsync, "fsync", "Latency of a file sync operation");
   logger.reset(plb.create_perf_counters());
   cct->get_perfcounters_collection()->add(logger.get());
 
@@ -9013,6 +9015,8 @@ int64_t Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl)
   int64_t r = 0;
   const auto& conf = cct->_conf;
   Inode *in = f->inode.get();
+  utime_t lat;
+  utime_t start = ceph_clock_now(); 
 
   if ((f->mode & CEPH_FILE_MODE_RD) == 0)
     return -EBADF;
@@ -9114,10 +9118,14 @@ success:
     // adjust fd pos
     f->pos = start_pos + r;
   }
+  
+  lat = ceph_clock_now();
+  lat -= start;
+  logger->tinc(l_c_read, lat);
 
 done:
   // done!
-
+  
   if (onuninline) {
     client_lock.Unlock();
     int ret = onuninline->wait();
@@ -9705,6 +9713,8 @@ int Client::_fsync(Inode *in, bool syncdataonly)
   std::unique_ptr<C_SaferCond> object_cacher_completion = nullptr;
   ceph_tid_t flush_tid = 0;
   InodeRef tmp_ref;
+  utime_t lat;
+  utime_t start = ceph_clock_now(); 
 
   ldout(cct, 8) << "_fsync on " << *in << " " << (syncdataonly ? "(dataonly)":"(data+metadata)") << dendl;
   
@@ -9756,6 +9766,10 @@ int Client::_fsync(Inode *in, bool syncdataonly)
     ldout(cct, 8) << "ino " << in->ino << " failed to commit to disk! "
                  << cpp_strerror(-r) << dendl;
   }
+   
+  lat = ceph_clock_now();
+  lat -= start;
+  logger->tinc(l_c_fsync, lat);
 
   return r;
 }
index eb882b33477c4946b22bd1205accee9e1aa7ce4c..cc9816689e8f5266aa4dacba3ed93ce9ab8c32ef 100644 (file)
@@ -79,6 +79,8 @@ enum {
   l_c_reply,
   l_c_lat,
   l_c_wrlat,
+  l_c_read,
+  l_c_fsync,
   l_c_last,
 };