From: Samuel Just Date: Wed, 14 Aug 2013 00:36:57 +0000 (-0700) Subject: ObjectStore: add ObjectStore::get_cur_stats and impl in FileStore X-Git-Tag: v0.67.5~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ec086df1beccda6d5a6c12c727c84c2555b0b2cd;p=ceph.git ObjectStore: add ObjectStore::get_cur_stats and impl in FileStore Signed-off-by: Samuel Just (cherry picked from commit ebde89d5602536b4bc651737e4280fdfb6634c32) --- diff --git a/src/common/perf_counters.cc b/src/common/perf_counters.cc index 1dd4cdabd9d..339ff6a372b 100644 --- a/src/common/perf_counters.cc +++ b/src/common/perf_counters.cc @@ -203,6 +203,22 @@ utime_t PerfCounters::tget(int idx) const return utime_t(data.u64 / 1000000000ull, data.u64 % 1000000000ull); } +pair 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); diff --git a/src/common/perf_counters.h b/src/common/perf_counters.h index ec10f9a9282..f4651c69f1c 100644 --- a/src/common/perf_counters.h +++ b/src/common/perf_counters.h @@ -65,6 +65,24 @@ enum perfcounter_type_d class PerfCounters { public: + template + struct avg_tracker { + pair last; + pair 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 &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 get_tavg_ms(int idx) const; + const std::string& get_name() const; void set_name(std::string s) { m_name = s; diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 62e90221226..ff2135c4815 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -142,6 +142,17 @@ static CompatSet get_fs_supported_compat_set() { #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) { diff --git a/src/os/FileStore.h b/src/os/FileStore.h index fd85c7714f3..99072e959d6 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -75,6 +75,25 @@ class FileStore : public JournalingObjectStore, public md_config_obs_t { public: + + struct FSPerfTracker { + PerfCounters::avg_tracker os_commit_latency; + PerfCounters::avg_tracker 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 diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 6bfefa09a47..eb5b40c5a69 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -81,6 +81,8 @@ public: Logger *logger; + virtual filestore_perf_stat_t get_cur_stats() = 0; + /** * a sequencer orders transactions * diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index bac7415157e..92904527f83 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3668,6 +3668,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();