]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add onode/buffer cache statistics
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 2 Sep 2016 03:33:33 +0000 (11:33 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 2 Sep 2016 06:11:41 +0000 (14:11 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 3d8aa8df126b831d2c903fc437aa734a65d1fecd..f19070f38d58874ac8b67fbb02de4b286f4b5163 100644 (file)
@@ -976,6 +976,8 @@ void BlueStore::BufferSpace::read(
 {
   std::lock_guard<std::mutex> l(cache->lock);
   res.clear();
+  res_intervals.clear();
+  uint64_t want_bytes = length;
   uint64_t end = offset + length;
   for (auto i = _data_lower_bound(offset);
        i != buffer_map.end() && offset < end && i->first < end;
@@ -1020,6 +1022,12 @@ void BlueStore::BufferSpace::read(
       }
     }
   }
+
+  uint64_t hit_bytes = res_intervals.size();
+  assert(hit_bytes <= want_bytes);
+  uint64_t miss_bytes = want_bytes - hit_bytes;
+  cache->store->logger->inc(l_bluestore_buffer_hit_bytes, hit_bytes);
+  cache->store->logger->inc(l_bluestore_buffer_miss_bytes, miss_bytes);
 }
 
 void BlueStore::BufferSpace::finish_write(uint64_t seq)
@@ -1075,10 +1083,12 @@ BlueStore::OnodeRef BlueStore::OnodeSpace::lookup(const ghobject_t& oid)
   ceph::unordered_map<ghobject_t,OnodeRef>::iterator p = onode_map.find(oid);
   if (p == onode_map.end()) {
     dout(30) << __func__ << " " << oid << " miss" << dendl;
+    cache->store->logger->inc(l_bluestore_onode_misses);
     return OnodeRef();
   }
   dout(30) << __func__ << " " << oid << " hit " << p->second << dendl;
   cache->_touch_onode(p->second);
+  cache->store->logger->inc(l_bluestore_onode_hits);
   return p->second;
 }
 
@@ -1547,31 +1557,64 @@ void BlueStore::_init_logger()
 {
   PerfCountersBuilder b(g_ceph_context, "BlueStore",
                         l_bluestore_first, l_bluestore_last);
-  b.add_time_avg(l_bluestore_state_prepare_lat, "state_prepare_lat", "Average prepare state latency");
-  b.add_time_avg(l_bluestore_state_aio_wait_lat, "state_aio_wait_lat", "Average aio_wait state latency");
-  b.add_time_avg(l_bluestore_state_io_done_lat, "state_io_done_lat", "Average io_done state latency");
-  b.add_time_avg(l_bluestore_state_kv_queued_lat, "state_kv_queued_lat", "Average kv_queued state latency");
-  b.add_time_avg(l_bluestore_state_kv_committing_lat, "state_kv_commiting_lat", "Average kv_commiting state latency");
-  b.add_time_avg(l_bluestore_state_kv_done_lat, "state_kv_done_lat", "Average kv_done state latency");
-  b.add_time_avg(l_bluestore_state_wal_queued_lat, "state_wal_queued_lat", "Average wal_queued state latency");
-  b.add_time_avg(l_bluestore_state_wal_applying_lat, "state_wal_applying_lat", "Average wal_applying state latency");
-  b.add_time_avg(l_bluestore_state_wal_aio_wait_lat, "state_wal_aio_wait_lat", "Average aio_wait state latency");
-  b.add_time_avg(l_bluestore_state_wal_cleanup_lat, "state_wal_cleanup_lat", "Average cleanup state latency");
-  b.add_time_avg(l_bluestore_state_finishing_lat, "state_finishing_lat", "Average finishing state latency");
-  b.add_time_avg(l_bluestore_state_done_lat, "state_done_lat", "Average done state latency");
-  b.add_time_avg(l_bluestore_compress_lat, "compress_lat", "Average compress latency");
-  b.add_time_avg(l_bluestore_decompress_lat, "decompress_lat", "Average decompress latency");
-  b.add_u64(l_bluestore_compress_success_count, "compress_success_count", "Sum for beneficial compress ops");
-
-  b.add_u64(l_bluestore_write_pad_bytes, "write_pad_bytes", "Sum for write-op padded bytes");
-  b.add_u64(l_bluestore_wal_write_ops, "wal_write_ops", "Sum for wal write op");
-  b.add_u64(l_bluestore_wal_write_bytes, "wal_write_bytes", "Sum for wal write bytes");
-  b.add_u64(l_bluestore_write_penalty_read_ops, " write_penalty_read_ops", "Sum for write penalty read ops");
-  b.add_u64(l_bluestore_allocated, "bluestore_allocated", "Sum for allocated bytes");
-  b.add_u64(l_bluestore_stored, "bluestore_stored", "Sum for stored bytes");
-  b.add_u64(l_bluestore_compressed, "bluestore_compressed", "Sum for stored compressed bytes");
-  b.add_u64(l_bluestore_compressed_allocated, "bluestore_compressed_allocated", "Sum for bytes allocated for compressed data");
-  b.add_u64(l_bluestore_compressed_original, "bluestore_compressed_original", "Sum for original bytes that were compressed");
+  b.add_time_avg(l_bluestore_state_prepare_lat, "state_prepare_lat",
+    "Average prepare state latency");
+  b.add_time_avg(l_bluestore_state_aio_wait_lat, "state_aio_wait_lat",
+    "Average aio_wait state latency");
+  b.add_time_avg(l_bluestore_state_io_done_lat, "state_io_done_lat",
+    "Average io_done state latency");
+  b.add_time_avg(l_bluestore_state_kv_queued_lat, "state_kv_queued_lat",
+    "Average kv_queued state latency");
+  b.add_time_avg(l_bluestore_state_kv_committing_lat, "state_kv_commiting_lat",
+    "Average kv_commiting state latency");
+  b.add_time_avg(l_bluestore_state_kv_done_lat, "state_kv_done_lat",
+    "Average kv_done state latency");
+  b.add_time_avg(l_bluestore_state_wal_queued_lat, "state_wal_queued_lat",
+    "Average wal_queued state latency");
+  b.add_time_avg(l_bluestore_state_wal_applying_lat, "state_wal_applying_lat",
+    "Average wal_applying state latency");
+  b.add_time_avg(l_bluestore_state_wal_aio_wait_lat, "state_wal_aio_wait_lat",
+    "Average aio_wait state latency");
+  b.add_time_avg(l_bluestore_state_wal_cleanup_lat, "state_wal_cleanup_lat",
+    "Average cleanup state latency");
+  b.add_time_avg(l_bluestore_state_finishing_lat, "state_finishing_lat",
+    "Average finishing state latency");
+  b.add_time_avg(l_bluestore_state_done_lat, "state_done_lat",
+    "Average done state latency");
+  b.add_time_avg(l_bluestore_compress_lat, "compress_lat",
+    "Average compress latency");
+  b.add_time_avg(l_bluestore_decompress_lat, "decompress_lat",
+    "Average decompress latency");
+  b.add_u64(l_bluestore_compress_success_count, "compress_success_count",
+    "Sum for beneficial compress ops");
+
+  b.add_u64(l_bluestore_write_pad_bytes, "write_pad_bytes",
+    "Sum for write-op padded bytes");
+  b.add_u64(l_bluestore_wal_write_ops, "wal_write_ops",
+    "Sum for wal write op");
+  b.add_u64(l_bluestore_wal_write_bytes, "wal_write_bytes",
+    "Sum for wal write bytes");
+  b.add_u64(l_bluestore_write_penalty_read_ops, " write_penalty_read_ops",
+    "Sum for write penalty read ops");
+  b.add_u64(l_bluestore_allocated, "bluestore_allocated",
+    "Sum for allocated bytes");
+  b.add_u64(l_bluestore_stored, "bluestore_stored",
+    "Sum for stored bytes");
+  b.add_u64(l_bluestore_compressed, "bluestore_compressed",
+    "Sum for stored compressed bytes");
+  b.add_u64(l_bluestore_compressed_allocated, "bluestore_compressed_allocated",
+    "Sum for bytes allocated for compressed data");
+  b.add_u64(l_bluestore_compressed_original, "bluestore_compressed_original",
+    "Sum for original bytes that were compressed");
+
+  b.add_u64(l_bluestore_onode_hits, "bluestore_onode_hits",
+    "Sum for onode-lookups hit in the cache");
+  b.add_u64(l_bluestore_onode_misses, "bluestore_onode_misses",
+    "Sum for onode-lookups missed in the cache");
+  b.add_u64(l_bluestore_buffer_hit_bytes, "bluestore_buffer_hit_bytes",
+    "Sum for bytes of read hit in the cache");
+  b.add_u64(l_bluestore_buffer_miss_bytes, "bluestore_buffer_miss_bytes",
+    "Sum for bytes of read missed in the cache");
   logger = b.create_perf_counters();
   g_ceph_context->get_perfcounters_collection()->add(logger);
 }
@@ -2768,6 +2811,7 @@ void BlueStore::set_cache_shards(unsigned num)
   cache_shards.resize(num);
   for (unsigned i = old; i < num; ++i) {
     cache_shards[i] = Cache::create(g_conf->bluestore_cache_type);
+    cache_shards[i]->set_store(this);
   }
 }
 
index 11c124f5bb0c9611b980a1bc01f626ada53b3a13..874cd5aff4e9b695562f80a4a64301380a8eee1f 100644 (file)
@@ -70,6 +70,10 @@ enum {
   l_bluestore_compressed,
   l_bluestore_compressed_allocated,
   l_bluestore_compressed_original,
+  l_bluestore_onode_hits,
+  l_bluestore_onode_misses,
+  l_bluestore_buffer_hit_bytes,
+  l_bluestore_buffer_miss_bytes,
   l_bluestore_last
 };
 
@@ -569,10 +573,13 @@ public:
 
   /// a cache (shard) of onodes and buffers
   struct Cache {
+    BlueStore *store;
     std::mutex lock;                ///< protect lru and other structures
 
     static Cache *create(string type);
 
+    void set_store(BlueStore *bs) { store = bs; }
+
     virtual ~Cache() {}
 
     virtual void _add_onode(OnodeRef& o, int level) = 0;