Commit d92b1b90 authored by Philip Pronin's avatar Philip Pronin Committed by ptarjan

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
parent bfdcbc20
......@@ -234,7 +234,7 @@ class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
!NodeType::template destroyIsNoOp<NodeAlloc>()>::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<NodeType, NodeAlloc, typename std::enable_if<
return refs_.load(std::memory_order_relaxed);
}
NodeAlloc alloc_;
std::unique_ptr<std::vector<NodeType*>> nodes_;
std::atomic<int32_t> refs_; // current number of visitors to the list
std::atomic<bool> 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment