That namespace contains a set of common STL containers that are predefined
with the appropriate allocators.
-Thus for mempool "unittest_1" we have automatically available to us:
+Thus for mempool "osd" we have automatically available to us:
- mempool::unittest_1::map
- mempool::unittest_1::multimap
- mempool::unittest_1::set
- mempool::unittest_1::multiset
- mempool::unittest_1::list
- mempool::unittest_1::vector
- mempool::unittest_1::unordered_map
+ mempool::osd::map
+ mempool::osd::multimap
+ mempool::osd::set
+ mempool::osd::multiset
+ mempool::osd::list
+ mempool::osd::vector
+ mempool::osd::unordered_map
Putting objects in a mempool
Then, in an appropriate .cc file,
- MEMPOOL_DEFINE_OBJECT_FACTORY(Foo, foo, unittest_1);
+ MEMPOOL_DEFINE_OBJECT_FACTORY(Foo, foo, osd);
The second argument can generally be identical to the first, except
when the type contains a nested scope. For example, for
(This is just because we need to name some static variables and we
can't use :: in a variable name.)
+XXX Note: the new operator hard-codes the allocation size to the size of the
+object given in MEMPOOL_DEFINE_OBJECT_FACTORY. For this reason, you cannot
+incorporate mempools into a base class without also defining a helper/factory
+for the child class as well (as the base class is usually smaller than the
+child class).
+
In order to use the STL containers, simply use the namespaced variant
of the container type. For example,
- mempool::unittest_1::map<int> myvec;
+ mempool::osd::map<int> myvec;
Introspection
-------------
#define DEFINE_MEMORY_POOLS_HELPER(f) \
f(bloom_filter) \
- f(bluestore_meta_onode) \
- f(bluestore_meta_other) \
f(bluestore_alloc) \
+ f(bluestore_cache_data) \
+ f(bluestore_cache_onode) \
+ f(bluestore_cache_other) \
f(bluestore_fsck) \
+ f(bluestore_txc) \
+ f(bluestore_writing_deferred) \
+ f(bluestore_writing) \
f(bluefs) \
+ f(buffer_anon) \
f(buffer_meta) \
- f(buffer_data) \
f(osd) \
+ f(osd_mapbl) \
+ f(osd_pglog) \
f(osdmap) \
f(osdmap_mapping) \
+ f(pgmap) \
+ f(mds_co) \
f(unittest_1) \
f(unittest_2)
f->dump_int("items", items);
f->dump_int("bytes", bytes);
}
+
+ stats_t& operator+=(const stats_t& o) {
+ items += o.items;
+ bytes += o.bytes;
+ return *this;
+ }
};
pool_t& get_pool(pool_index_t ix);
size_t allocated_bytes() const;
size_t allocated_items() const;
+ void adjust_count(ssize_t items, ssize_t bytes);
+
shard_t* pick_a_shard() {
// Dirt cheap, see:
// http://fossies.org/dox/glibc-2.24/pthread__self_8c_source.html
void get_stats(stats_t *total,
std::map<std::string, stats_t> *by_type) const;
- void dump(ceph::Formatter *f) const;
+ void dump(ceph::Formatter *f, stats_t *ptotal=0) const;
};
void dump(ceph::Formatter *f);