]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: drop allocation tracking from bufferlist. 25454/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 6 Dec 2018 17:44:33 +0000 (18:44 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 7 Dec 2018 21:41:02 +0000 (22:41 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/buffer.cc
src/include/buffer.h
src/mds/MDCache.cc
src/mds/MDSRank.cc
src/mds/MDSRank.h
src/osd/OSD.cc
src/osd/OSD.h
src/test/CMakeLists.txt
src/test/bufferlist.cc
src/unittest_bufferlist.sh [deleted file]

index b1c533ed3100fb2b08891bd1e4e7bf98c523c887..49f95cf85fe579e0ca59908902e6fcabce56aeea 100644 (file)
@@ -52,41 +52,6 @@ using namespace ceph;
 # define bendl std::endl; }
 #endif
 
-  static std::atomic<uint64_t> buffer_total_alloc { 0 };
-  static std::atomic<uint64_t> buffer_history_alloc_bytes { 0 };
-  static std::atomic<uint64_t> buffer_history_alloc_num { 0 };
-
-  const bool buffer_track_alloc = get_env_bool("CEPH_BUFFER_TRACK");
-
-  namespace {
-  void inc_total_alloc(unsigned len) {
-    if (buffer_track_alloc)
-      buffer_total_alloc += len;
-  }
-
-  void dec_total_alloc(unsigned len) {
-    if (buffer_track_alloc)
-      buffer_total_alloc -= len;
-  }
-
-  void inc_history_alloc(uint64_t len) {
-    if (buffer_track_alloc) {
-      buffer_history_alloc_bytes += len;
-      buffer_history_alloc_num++;
-    }
-  }
-  } // namespace
-
-  int buffer::get_total_alloc() {
-    return buffer_total_alloc;
-  }
-  uint64_t buffer::get_history_alloc_bytes() {
-    return buffer_history_alloc_bytes;
-  }
-  uint64_t buffer::get_history_alloc_num() {
-    return buffer_history_alloc_num;
-  }
-
   static std::atomic<unsigned> buffer_cached_crc { 0 };
   static std::atomic<unsigned> buffer_cached_crc_adjusted { 0 };
   static std::atomic<unsigned> buffer_missed_crc { 0 };
@@ -180,11 +145,6 @@ using namespace ceph;
                 int mempool)
       : raw(dataptr, l, mempool),
        alignment(align) {
-      inc_total_alloc(len);
-      inc_history_alloc(len);
-    }
-    ~raw_combined() override {
-      dec_total_alloc(len);
     }
     raw* clone_empty() override {
       return create(len, alignment);
@@ -233,18 +193,14 @@ using namespace ceph;
       } else {
        data = 0;
       }
-      inc_total_alloc(len);
-      inc_history_alloc(len);
-      bdout << "raw_malloc " << this << " alloc " << (void *)data << " " << l << " " << buffer::get_total_alloc() << bendl;
+      bdout << "raw_malloc " << this << " alloc " << (void *)data << " " << l << bendl;
     }
     raw_malloc(unsigned l, char *b) : raw(b, l) {
-      inc_total_alloc(len);
-      bdout << "raw_malloc " << this << " alloc " << (void *)data << " " << l << " " << buffer::get_total_alloc() << bendl;
+      bdout << "raw_malloc " << this << " alloc " << (void *)data << " " << l << bendl;
     }
     ~raw_malloc() override {
       free(data);
-      dec_total_alloc(len);
-      bdout << "raw_malloc " << this << " free " << (void *)data << " " << buffer::get_total_alloc() << bendl;
+      bdout << "raw_malloc " << this << " free " << (void *)data << " " << bendl;
     }
     raw* clone_empty() override {
       return new raw_malloc(len);
@@ -269,14 +225,12 @@ using namespace ceph;
 #endif /* DARWIN */
       if (!data)
        throw bad_alloc();
-      inc_total_alloc(len);
-      inc_history_alloc(len);
-      bdout << "raw_posix_aligned " << this << " alloc " << (void *)data << " l=" << l << ", align=" << align << " total_alloc=" << buffer::get_total_alloc() << bendl;
+      bdout << "raw_posix_aligned " << this << " alloc " << (void *)data
+           << " l=" << l << ", align=" << align << bendl;
     }
     ~raw_posix_aligned() override {
       ::free(data);
-      dec_total_alloc(len);
-      bdout << "raw_posix_aligned " << this << " free " << (void *)data << " " << buffer::get_total_alloc() << bendl;
+      bdout << "raw_posix_aligned " << this << " free " << (void *)data << bendl;
     }
     raw* clone_empty() override {
       return new raw_posix_aligned(len, align);
@@ -297,8 +251,6 @@ using namespace ceph;
        data = realdata + align - off;
       else
        data = realdata;
-      inc_total_alloc(len+align-1);
-      inc_history_alloc(len+align-1);
       //cout << "hack aligned " << (unsigned)data
       //<< " in raw " << (unsigned)realdata
       //<< " off " << off << std::endl;
@@ -306,7 +258,6 @@ using namespace ceph;
     }
     ~raw_hack_aligned() {
       delete[] realdata;
-      dec_total_alloc(len+align-1);
     }
     raw* clone_empty() {
       return new raw_hack_aligned(len, align);
@@ -326,18 +277,14 @@ using namespace ceph;
        data = new char[len];
       else
        data = 0;
-      inc_total_alloc(len);
-      inc_history_alloc(len);
-      bdout << "raw_char " << this << " alloc " << (void *)data << " " << l << " " << buffer::get_total_alloc() << bendl;
+      bdout << "raw_char " << this << " alloc " << (void *)data << " " << l << bendl;
     }
     raw_char(unsigned l, char *b) : raw(b, l) {
-      inc_total_alloc(len);
-      bdout << "raw_char " << this << " alloc " << (void *)data << " " << l << " " << buffer::get_total_alloc() << bendl;
+      bdout << "raw_char " << this << " alloc " << (void *)data << " " << l << bendl;
     }
     ~raw_char() override {
       delete[] data;
-      dec_total_alloc(len);
-      bdout << "raw_char " << this << " free " << (void *)data << " " << buffer::get_total_alloc() << bendl;
+      bdout << "raw_char " << this << " free " << (void *)data << bendl;
     }
     raw* clone_empty() override {
       return new raw_char(len);
@@ -349,14 +296,12 @@ using namespace ceph;
     MEMPOOL_CLASS_HELPERS();
 
     explicit raw_claimed_char(unsigned l, char *b) : raw(b, l) {
-      inc_total_alloc(len);
       bdout << "raw_claimed_char " << this << " alloc " << (void *)data
-           << " " << l << " " << buffer::get_total_alloc() << bendl;
+           << " " << l << bendl;
     }
     ~raw_claimed_char() override {
-      dec_total_alloc(len);
       bdout << "raw_claimed_char " << this << " free " << (void *)data
-           << " " << buffer::get_total_alloc() << bendl;
+           << bendl;
     }
     raw* clone_empty() override {
       return new raw_char(len);
index 56c5e8154e2866e42d63a2582aa836b2172fe8ae..80b50d0cfd5bcd1e56f2aa26722577f4a5082dd2 100644 (file)
@@ -113,18 +113,6 @@ namespace buffer CEPH_BUFFER_API {
   };
 
 
-  /// total bytes allocated
-  int get_total_alloc();
-
-  /// history total bytes allocated
-  uint64_t get_history_alloc_bytes();
-
-  /// total num allocated
-  uint64_t get_history_alloc_num();
-
-  /// enable/disable alloc tracking
-  void track_alloc(bool b);
-
   /// count of cached crc hits (matching input)
   int get_cached_crc();
   /// count of cached crc hits (mismatching input, required adjustment)
index a83c52142e3c93266a2b9914d424df6ed9437a37..7fe58874517205fdb3cac0da50f853ef046f5b5b 100644 (file)
@@ -7530,7 +7530,6 @@ void MDCache::check_memory_usage()
           << ", rss " << last.get_rss()
           << ", heap " << last.get_heap()
           << ", baseline " << baseline.get_heap()
-          << ", buffers " << (buffer::get_total_alloc() >> 10)
           << ", " << num_inodes_with_caps << " / " << CInode::count() << " inodes have caps"
           << ", " << Capability::count() << " caps, " << caps_per_inode << " caps per inode"
           << dendl;
index faa1a92464df7277935fe2b5abee8fe9a08fac36..6290ca90744d700f1a228514c4a6dbcfdc8d6456 100644 (file)
@@ -1103,7 +1103,6 @@ void MDSRank::update_mlogger()
     mlogger->set(l_mdm_dns, CDentry::decrements());
     mlogger->set(l_mdm_capa, Capability::increments());
     mlogger->set(l_mdm_caps, Capability::decrements());
-    mlogger->set(l_mdm_buf, buffer::get_total_alloc());
   }
 }
 
@@ -3109,7 +3108,6 @@ void MDSRank::create_logger()
     mdm_plb.add_u64_counter(l_mdm_capa, "cap+", "Capabilities added");
     mdm_plb.add_u64_counter(l_mdm_caps, "cap-", "Capabilities removed");
     mdm_plb.add_u64(l_mdm_heap, "heap", "Heap size");
-    mdm_plb.add_u64(l_mdm_buf, "buf", "Buffer size");
 
     mdm_plb.set_prio_default(PerfCountersBuilder::PRIO_DEBUGONLY);
     mdm_plb.add_u64(l_mdm_rss, "rss", "RSS");
index 10a533a1e595788a91b8e268f31b7a864d0d4569..19044e26d50d2f224a76eaf320ec6e3ad6e4d49e 100644 (file)
@@ -97,7 +97,6 @@ enum {
   l_mdm_caps,
   l_mdm_rss,
   l_mdm_heap,
-  l_mdm_buf,
   l_mdm_last,
 };
 
index 06f945ecbe51d988fca26b3f542123c990ce5fe7..b260d0d400082826f41824e4c4ff6bbefd2b692c 100644 (file)
@@ -3336,9 +3336,6 @@ void OSD::create_logger()
    "rbt", PerfCountersBuilder::PRIO_INTERESTING);
 
   osd_plb.add_u64(l_osd_loadavg, "loadavg", "CPU load");
-  osd_plb.add_u64(l_osd_buf, "buffer_bytes", "Total allocated buffer size", NULL, 0, unit_t(UNIT_BYTES));
-  osd_plb.add_u64(l_osd_history_alloc_bytes, "history_alloc_Mbytes", NULL, 0, unit_t(UNIT_BYTES));
-  osd_plb.add_u64(l_osd_history_alloc_num, "history_alloc_num");
   osd_plb.add_u64(
     l_osd_cached_crc, "cached_crc", "Total number getting crc from crc_cache");
   osd_plb.add_u64(
@@ -5059,9 +5056,6 @@ void OSD::tick_without_osd_lock()
   ceph_assert(tick_timer_lock.is_locked());
   dout(10) << "tick_without_osd_lock" << dendl;
 
-  logger->set(l_osd_buf, buffer::get_total_alloc());
-  logger->set(l_osd_history_alloc_bytes, shift_round_up(buffer::get_history_alloc_bytes(), 20));
-  logger->set(l_osd_history_alloc_num, buffer::get_history_alloc_num());
   logger->set(l_osd_cached_crc, buffer::get_cached_crc());
   logger->set(l_osd_cached_crc_adjusted, buffer::get_cached_crc_adjusted());
   logger->set(l_osd_missed_crc, buffer::get_missed_crc());
index 7253e9aa14a7cc60b7e15c38a365400bd4e9a01f..246576e8400086c80cace979efe7ac883cbd6aff 100644 (file)
@@ -124,9 +124,6 @@ enum {
   l_osd_rbytes,
 
   l_osd_loadavg,
-  l_osd_buf,
-  l_osd_history_alloc_bytes,
-  l_osd_history_alloc_num,
   l_osd_cached_crc,
   l_osd_cached_crc_adjusted,
   l_osd_missed_crc,
index ec250fc7214b84e23616ce6f9f5e998aebbb0c58..5876bd8d610b787d7f935e10008b910ee9a5e5a5 100644 (file)
@@ -534,7 +534,6 @@ add_ceph_test(test_objectstore_memstore.sh ${CMAKE_CURRENT_SOURCE_DIR}/test_obje
 #add_ceph_test(test_pidfile.sh ${CMAKE_CURRENT_SOURCE_DIR}/test_pidfile.sh)
 
 add_ceph_test(smoke.sh ${CMAKE_CURRENT_SOURCE_DIR}/smoke.sh)
-add_ceph_test(unittest_bufferlist.sh ${CMAKE_SOURCE_DIR}/src/unittest_bufferlist.sh)
 
 # XXX are these safe to remove? they used to be around for ceph-disk tox testing
 set(env_vars_for_tox_tests
index beb094fd83139081a3e268bcb7c9cd2de77450eb..7e5d3c45aff48adffe4af5a1f1ef973edf30871b 100644 (file)
 static char cmd[128];
 
 TEST(Buffer, constructors) {
-  bool ceph_buffer_track = get_env_bool("CEPH_BUFFER_TRACK");
   unsigned len = 17;
-  uint64_t history_alloc_bytes = 0;
-  uint64_t history_alloc_num = 0;
   //
   // buffer::create
   //
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
-  }
-  
   {
     bufferptr ptr(buffer::create(len));
-    history_alloc_bytes += len;
-    history_alloc_num++;
     EXPECT_EQ(len, ptr.length());
-    if (ceph_buffer_track) {
-      EXPECT_EQ(len, (unsigned)buffer::get_total_alloc());
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
   }
   //
   // buffer::claim_char
   //
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
-  }
-  
   {
     char* str = new char[len];
     ::memset(str, 'X', len);
     bufferptr ptr(buffer::claim_char(len, str));
-    if (ceph_buffer_track) {
-      EXPECT_EQ(len, (unsigned)buffer::get_total_alloc());
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
     EXPECT_EQ(len, ptr.length());
     EXPECT_EQ(str, ptr.c_str());
     bufferptr clone = ptr.clone();
-    history_alloc_bytes += len;
-    history_alloc_num++;
     EXPECT_EQ(0, ::memcmp(clone.c_str(), ptr.c_str(), len));
     delete [] str;
   }
   //
   // buffer::create_static
   //
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
-  }
-  
   {
     char* str = new char[len];
     bufferptr ptr(buffer::create_static(len, str));
-    if (ceph_buffer_track) {
-      EXPECT_EQ(0, buffer::get_total_alloc());
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
     EXPECT_EQ(len, ptr.length());
     EXPECT_EQ(str, ptr.c_str());
     delete [] str;
@@ -112,19 +78,8 @@ TEST(Buffer, constructors) {
   //
   // buffer::create_malloc
   //
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
-  }
-  
   {
     bufferptr ptr(buffer::create_malloc(len));
-    history_alloc_bytes += len;
-    history_alloc_num++;
-    if (ceph_buffer_track) {
-      EXPECT_EQ(len, (unsigned)buffer::get_total_alloc());
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
     EXPECT_EQ(len, ptr.length());
     // this doesn't throw on my x86_64 wheezy box --sage
     //EXPECT_THROW(buffer::create_malloc((unsigned)ULLONG_MAX), buffer::bad_alloc);
@@ -132,79 +87,37 @@ TEST(Buffer, constructors) {
   //
   // buffer::claim_malloc
   //
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
-  }
-  
   {
     char* str = (char*)malloc(len);
     ::memset(str, 'X', len);
     bufferptr ptr(buffer::claim_malloc(len, str));
-    if (ceph_buffer_track) {
-      EXPECT_EQ(len, (unsigned)buffer::get_total_alloc());
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
     EXPECT_EQ(len, ptr.length());
     EXPECT_EQ(str, ptr.c_str());
     bufferptr clone = ptr.clone();
-    history_alloc_bytes += len;
-    history_alloc_num++;
     EXPECT_EQ(0, ::memcmp(clone.c_str(), ptr.c_str(), len));
   }
   //
   // buffer::copy
   //
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
-  }
-  
   {
     const std::string expected(len, 'X');
     bufferptr ptr(buffer::copy(expected.c_str(), expected.size()));
-    history_alloc_bytes += len;
-    history_alloc_num++;
-    if (ceph_buffer_track) {
-      EXPECT_EQ(len, (unsigned)buffer::get_total_alloc());
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
     EXPECT_NE(expected.c_str(), ptr.c_str());
     EXPECT_EQ(0, ::memcmp(expected.c_str(), ptr.c_str(), len));
   }
   //
   // buffer::create_page_aligned
   //
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
-  }
-  
   {
     bufferptr ptr(buffer::create_page_aligned(len));
-    history_alloc_bytes += len;
-    history_alloc_num++;
     ::memset(ptr.c_str(), 'X', len);
-    if (ceph_buffer_track) {
-      EXPECT_EQ(len, (unsigned)buffer::get_total_alloc());
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
     // doesn't throw on my x86_64 wheezy box --sage
     //EXPECT_THROW(buffer::create_page_aligned((unsigned)ULLONG_MAX), buffer::bad_alloc);
 #ifndef DARWIN
     ASSERT_TRUE(ptr.is_page_aligned());
 #endif // DARWIN 
     bufferptr clone = ptr.clone();
-    history_alloc_bytes += len;
-    history_alloc_num++;
     EXPECT_EQ(0, ::memcmp(clone.c_str(), ptr.c_str(), len));
-    if (ceph_buffer_track) {
-      EXPECT_EQ(history_alloc_bytes, buffer::get_history_alloc_bytes());
-      EXPECT_EQ(history_alloc_num, buffer::get_history_alloc_num());
-    }
-  }
-  if (ceph_buffer_track) {
-    EXPECT_EQ(0, buffer::get_total_alloc());
   }
 }
 
@@ -2930,7 +2843,7 @@ TEST(BufferHash, all) {
 /*
  * Local Variables:
  * compile-command: "cd .. ; make unittest_bufferlist && 
- *    ulimit -s unlimited ; CEPH_BUFFER_TRACK=true valgrind \
+ *    ulimit -s unlimited ; valgrind \
  *    --max-stackframe=20000000 --tool=memcheck \
  *    ./unittest_bufferlist # --gtest_filter=BufferList.constructors"
  * End:
diff --git a/src/unittest_bufferlist.sh b/src/unittest_bufferlist.sh
deleted file mode 100755 (executable)
index 5c0b62f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-#
-# Ceph - scalable distributed file system
-#
-# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
-#
-# Author: Loic Dachary <loic@dachary.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Library Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Library Public License for more details.
-#
-CEPH_BUFFER_TRACK=true unittest_bufferlist