Commit e481eaf7 authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Facebook Github Bot

Fix RSS regression in IndexedMemPool

Reviewed By: nbronson

Differential Revision: D12973004

fbshipit-source-id: 46de0c9ef6760a412fd2753595480ecd7e0be678
parent 6551536f
...@@ -210,10 +210,18 @@ struct IndexedMemPool : boost::noncopyable { ...@@ -210,10 +210,18 @@ struct IndexedMemPool : boost::noncopyable {
assert(errno == ENOMEM); assert(errno == ENOMEM);
throw std::bad_alloc(); throw std::bad_alloc();
} }
// Atom is expected to be std::atomic, which is trivially
// constructible, so we can avoid explicitly initializing the
// slots which would cause the whole mapped area to be paged in.
//
// TODO: Switch to is_trivially_constructible once support
// for GCC 4.9 is dropped for this file.
if /* constexpr */ (!std::is_trivial<Atom<uint32_t>>::value) {
for (size_t i = 1; i < actualCapacity_ + 1; i++) { for (size_t i = 1; i < actualCapacity_ + 1; i++) {
// Atom is enforced above to be nothrow-default-constructible // Atom is enforced above to be nothrow-default-constructible
new (&slots_[i].localNext) Atom<uint32_t>(); new (&slots_[i].localNext) Atom<uint32_t>;
new (&slots_[i].globalNext) Atom<uint32_t>(); new (&slots_[i].globalNext) Atom<uint32_t>;
}
} }
} }
......
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