]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: remove boost::pool usage and use tcmalloc directly 12792/head
authorZhi Zhang <willzzhang@tencent.com>
Mon, 24 Apr 2017 06:37:37 +0000 (14:37 +0800)
committerZhi Zhang <willzzhang@tencent.com>
Mon, 24 Apr 2017 06:37:37 +0000 (14:37 +0800)
Signed-off-by: Zhi Zhang <zhangz.david@outlook.com>
src/mds/CDentry.cc
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Capability.h
src/mds/MDCache.cc

index 8790377858ea30d4af0672caa9aea7d143c08ba8..7eeba7e753cd591e834caef7cf02e173fb955965 100644 (file)
@@ -36,8 +36,6 @@ ostream& CDentry::print_db_line_prefix(ostream& out)
   return out << ceph_clock_now() << " mds." << dir->cache->mds->get_nodeid() << ".cache.den(" << dir->ino() << " " << name << ") ";
 }
 
-boost::pool<> CDentry::pool(sizeof(CDentry));
-
 LockType CDentry::lock_type(CEPH_LOCK_DN);
 LockType CDentry::versionlock_type(CEPH_LOCK_DVERSION);
 
index f9505875e0464bb6f4842d84b4c05d99f5b2b8a2..175ce4fc1e7662a48301c059b759529b83aa36d7 100644 (file)
@@ -121,16 +121,6 @@ public:
     linkage.remote_d_type = dt;
   }
 
-  static void *operator new(size_t num_bytes) {
-    void *n = pool.malloc();
-    if (!n)
-      throw std::bad_alloc();
-    return n;
-  }
-  void operator delete(void *p) {
-    pool.free(p);
-  }
-
   const char *pin_name(int p) const override {
     switch (p) {
     case PIN_INODEPIN: return "inodepin";
@@ -381,16 +371,6 @@ protected:
 
   version_t version;  // dir version when last touched.
   version_t projected_version;  // what it will be when i unlock/commit.
-
-
-private:
-  /*
-   * This class uses a boost::pool to handle allocation. This is *not*
-   * thread-safe, so don't do allocations from multiple threads!
-   *
-   * Alternatively, switch the pool to use a boost::singleton_pool.
-   */
-  static boost::pool<> pool;
 };
 
 ostream& operator<<(ostream& out, const CDentry& dn);
index 14d706fee4cba0e1abb4639578bdd41721ce9521..6be3a1658c6dd206b7e657a4dda61d61601a6d87 100644 (file)
@@ -74,8 +74,6 @@ public:
 // PINS
 //int cdir_pins[CDIR_NUM_PINS] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
 
-boost::pool<> CDir::pool(sizeof(CDir));
-
 
 ostream& operator<<(ostream& out, const CDir& dir)
 {
index 03c53dee744a56c05ddaeb481996604e17491ffc..309af4aba54cb99619f50a477d091617654e6ecc 100644 (file)
@@ -45,25 +45,6 @@ ostream& operator<<(ostream& out, const class CDir& dir);
 class CDir : public MDSCacheObject, public Counter<CDir> {
   friend ostream& operator<<(ostream& out, const class CDir& dir);
 
-  /*
-   * This class uses a boost::pool to handle allocation. This is *not*
-   * thread-safe, so don't do allocations from multiple threads!
-   *
-   * Alternatively, switch the pool to use a boost::singleton_pool.
-   */
-private:
-  static boost::pool<> pool;
-public:
-  static void *operator new(size_t num_bytes) { 
-    void *n = pool.malloc();
-    if (!n)
-      throw std::bad_alloc();
-    return n;
-  }
-  void operator delete(void *p) {
-    pool.free(p);
-  }
-
 public:
   // -- pins --
   static const int PIN_DNWAITER =     1;
index 617367b9bbc91a00a58161b025621afb8fe63256..a2541b6578d11f4e61f3f22d70a6b5a7a374cec3 100644 (file)
@@ -66,9 +66,6 @@ public:
 };
 
 
-boost::pool<> CInode::pool(sizeof(CInode));
-boost::pool<> Capability::pool(sizeof(Capability));
-
 LockType CInode::versionlock_type(CEPH_LOCK_IVERSION);
 LockType CInode::authlock_type(CEPH_LOCK_IAUTH);
 LockType CInode::linklock_type(CEPH_LOCK_ILINK);
index 1d6b210e0b4255ca55d58e4bb7ecc373393d45ed..8b8cdfe175bdfd846b7ba9139927ed068f2e688a 100644 (file)
@@ -129,27 +129,6 @@ WRITE_CLASS_ENCODER_FEATURES(InodeStore)
 
 // cached inode wrapper
 class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CInode> {
-  /*
-   * This class uses a boost::pool to handle allocation. This is *not*
-   * thread-safe, so don't do allocations from multiple threads!
-   *
-   * Alternatively, switch the pool to use a boost::singleton_pool.
-   */
-
-private:
-  static boost::pool<> pool;
-public:
-  static void *operator new(size_t num_bytes) { 
-    void *n = pool.malloc();
-    if (!n)
-      throw std::bad_alloc();
-    return n;
-  }
-  void operator delete(void *p) {
-    pool.free(p);
-  }
-
-
  public:
   // -- pins --
   static const int PIN_DIRFRAG =         -1; 
index 14d56aa5d33f6cb9ad2c131d5b195a92c836d23d..0aaeda5c203e5cc9748c5a93eb2fbe15aa269466 100644 (file)
@@ -128,16 +128,6 @@ public:
   }
   Capability(const Capability& other);  // no copying
 
-
-  static void *operator new(size_t num_bytes) {
-    void *n = pool.malloc();
-    if (!n)
-      throw std::bad_alloc();
-    return n;
-  }
-  void operator delete(void *p) {
-    pool.free(p);
-  }
   const Capability& operator=(const Capability& other);  // no copying
 
   int pending() { return _pending; }
@@ -336,7 +326,6 @@ public:
   xlist<Capability*>::item item_client_revoking_caps;
 
 private:
-  static boost::pool<> pool;
   CInode *inode;
   client_t client;
 
index fd023da19833ad700232b77eab8c53cf4952d20d..cce552b18181f6f56da9b2a5688be3411dae8319 100644 (file)
@@ -98,6 +98,8 @@
 
 #include "common/Timer.h"
 
+#include "perfglue/heap_profiler.h"
+
 using namespace std;
 
 #include "common/config.h"
@@ -7375,11 +7377,11 @@ void MDCache::check_memory_usage()
         g_conf->mds_cache_size * g_conf->mds_health_cache_threshold) {
     // Only do this once we are back in bounds: otherwise the releases would
     // slow down whatever process caused us to exceed bounds to begin with
-    dout(2) << "check_memory_usage: releasing unused space from pool allocators"
-            << dendl;
-    CInode::pool.release_memory();
-    CDir::pool.release_memory();
-    CDentry::pool.release_memory();
+    if (ceph_using_tcmalloc()) {
+      dout(2) << "check_memory_usage: releasing unused space from tcmalloc" 
+             << dendl;
+      ceph_heap_release_free_memory();
+    }
     exceeded_size_limit = false;
   }
 }