From: Philip Pronin Date: Tue, 8 Apr 2014 18:08:02 +0000 (-0700) Subject: fix ConcurrentSkipList::Recycler layout X-Git-Tag: v0.22.0~613 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d92b1b900c4cf319224c6497f2ff529120534ae5;p=folly.git fix ConcurrentSkipList::Recycler layout Summary: D1261546 introduced regression in `sizeof(ConcurrentSkipList)`. In case of `NodeAlloc = folly::SysAlloc`, size of an empty `NodeAlloc` struct is 1 byte, due to the alignment requirements of the next field, it got translated into wasting 8 bytes. Test Plan: fbconfig -r folly/test && fbmake opt -j32 @override-unit-failures Reviewed By: lucian@fb.com FB internal diff: D1264730 --- diff --git a/folly/ConcurrentSkipList-inl.h b/folly/ConcurrentSkipList-inl.h index c303ac03..11813f03 100644 --- a/folly/ConcurrentSkipList-inl.h +++ b/folly/ConcurrentSkipList-inl.h @@ -234,7 +234,7 @@ class NodeRecycler()>::type> { public: explicit NodeRecycler(const NodeAlloc& alloc) - : alloc_(alloc), refs_(0), dirty_(false) { lock_.init(); } + : refs_(0), dirty_(false), alloc_(alloc) { lock_.init(); } ~NodeRecycler() { CHECK_EQ(refs(), 0); @@ -304,11 +304,11 @@ class NodeRecycler> nodes_; std::atomic refs_; // current number of visitors to the list std::atomic dirty_; // whether *nodes_ is non-empty MicroSpinLock lock_; // protects access to *nodes_ + NodeAlloc alloc_; }; // In case of arena allocator, no recycling is necessary, and it's possible