]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ObjectStore: add ObjectStore::get_cur_stats and impl in FileStore
authorSamuel Just <sam.just@inktank.com>
Wed, 14 Aug 2013 00:36:57 +0000 (17:36 -0700)
committerSamuel Just <sam.just@inktank.com>
Wed, 14 Aug 2013 21:22:41 +0000 (14:22 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/common/perf_counters.cc
src/common/perf_counters.h
src/os/FileStore.cc
src/os/FileStore.h
src/os/ObjectStore.h
src/osd/OSD.cc

index 1dd4cdabd9d8533cef2194421728e38f9713d9d5..339ff6a372bbf453d11780de0a53b125fcc9fac1 100644 (file)
@@ -203,6 +203,22 @@ utime_t PerfCounters::tget(int idx) const
   return utime_t(data.u64 / 1000000000ull, data.u64 % 1000000000ull);
 }
 
+pair<uint64_t, uint64_t> PerfCounters::get_tavg_ms(int idx) const
+{
+  if (!m_cct->_conf->perf)
+    return make_pair(0, 0);
+
+  Mutex::Locker lck(m_lock);
+  assert(idx > m_lower_bound);
+  assert(idx < m_upper_bound);
+  const perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]);
+  if (!(data.type & PERFCOUNTER_TIME))
+    return make_pair(0, 0);
+  if (!(data.type & PERFCOUNTER_LONGRUNAVG))
+    return make_pair(0, 0);
+  return make_pair(data.avgcount, data.u64/1000000);
+}
+
 void PerfCounters::dump_formatted(Formatter *f, bool schema)
 {
   Mutex::Locker lck(m_lock);
index ec10f9a9282865325b038f96a6c3061022f4fa4a..f4651c69f1ca97da6b697765a8aa68f91181c591 100644 (file)
@@ -65,6 +65,24 @@ enum perfcounter_type_d
 class PerfCounters
 {
 public:
+  template <typename T>
+  struct avg_tracker {
+    pair<uint64_t, T> last;
+    pair<uint64_t, T> cur;
+    avg_tracker() : last(0, 0), cur(0, 0) {}
+    T avg() const {
+      if (cur.first == last.first)
+       return cur.first ?
+         cur.second / cur.first :
+         0; // no change, report avg over all time
+      return (cur.second - last.second) / (cur.first - last.first);
+    }
+    void consume_next(const pair<uint64_t, T> &next) {
+      last = cur;
+      cur = next;
+    }
+  };
+
   ~PerfCounters();
 
   void inc(int idx, uint64_t v = 1);
@@ -78,6 +96,8 @@ public:
 
   void dump_formatted(ceph::Formatter *f, bool schema);
 
+  pair<uint64_t, uint64_t> get_tavg_ms(int idx) const;
+
   const std::string& get_name() const;
   void set_name(std::string s) {
     m_name = s;
index 108a857ab9fc9a8403dc110557c04d0f9f2cd179..e442dd4fe2bf03f290a24225c80747898b4338c3 100644 (file)
@@ -126,6 +126,17 @@ static const __SWORD_TYPE XFS_SUPER_MAGIC(0x58465342);
 #define ALIGNED(x, by) (!((x) % (by)))
 #define ALIGN_UP(x, by) (ALIGNED((x), (by)) ? (x) : (ALIGN_DOWN((x), (by)) + (by)))
 
+void FileStore::FSPerfTracker::update_from_perfcounters(
+  PerfCounters &logger)
+{
+  os_commit_latency.consume_next(
+    logger.get_tavg_ms(
+      l_os_commit_lat));
+  os_apply_latency.consume_next(
+    logger.get_tavg_ms(
+      l_os_apply_lat));
+}
+
 
 ostream& operator<<(ostream& out, const FileStore::OpSequencer& s)
 {
index 86d267dddf1ccd454c57211ae8b00b34351b2ede..ba428093cdaf6227f04f4a8b03770802c58995f9 100644 (file)
@@ -55,6 +55,25 @@ class FileStore : public JournalingObjectStore,
                   public md_config_obs_t
 {
 public:
+
+  struct FSPerfTracker {
+    PerfCounters::avg_tracker<uint64_t> os_commit_latency;
+    PerfCounters::avg_tracker<uint64_t> os_apply_latency;
+
+    filestore_perf_stat_t get_cur_stats() const {
+      filestore_perf_stat_t ret;
+      ret.filestore_commit_latency = os_commit_latency.avg();
+      ret.filestore_apply_latency = os_apply_latency.avg();
+      return ret;
+    }
+
+    void update_from_perfcounters(PerfCounters &logger);
+  } perf_tracker;
+  filestore_perf_stat_t get_cur_stats() {
+    perf_tracker.update_from_perfcounters(*logger);
+    return perf_tracker.get_cur_stats();
+  }
+
   static const uint32_t on_disk_version = 3;
 private:
   string internal_name;         ///< internal name, used to name the perfcounter instance
index 6bfefa09a470ab3e8c8ecc0d057deb8e9a58c7c2..eb5b40c5a690e103993ffcb133955b23241a3e6e 100644 (file)
@@ -81,6 +81,8 @@ public:
 
   Logger *logger;
 
+  virtual filestore_perf_stat_t get_cur_stats() = 0;
+
   /**
    * a sequencer orders transactions
    *
index 1a77dae730ab7ba8f1e28aac91a1eb258ad708ea..14bdc87487ce7420c2e6b2c50c9a9ed00a026e49 100644 (file)
@@ -3648,6 +3648,8 @@ void OSD::send_pg_stats(const utime_t &now)
   stat_lock.Lock();
   osd_stat_t cur_stat = osd_stat;
   stat_lock.Unlock();
+
+  osd_stat.fs_perf_stat = store->get_cur_stats();
    
   pg_stat_queue_lock.Lock();