Commit 51f060fe authored by Shuai Ding's avatar Shuai Ding Committed by Tudor Bosman

change shared_ptr<>* to raw pointer

Summary:
change shared_ptr<>* to raw pointer in
forwardIndex in RTIndex. This saves 16 bytes per
forward list (decrease from 88 to 72) and translates
to about 4-5% memory saving for RTIndex in ff tier.

Test Plan: unit test

Reviewed By: xliux@fb.com

FB internal diff: D551191
parent 4a7f5a25
...@@ -145,11 +145,11 @@ class ConcurrentSkipList { ...@@ -145,11 +145,11 @@ class ConcurrentSkipList {
// being treated as a scalar in the compiler). // being treated as a scalar in the compiler).
static_assert(MAX_HEIGHT >= 2 && MAX_HEIGHT < 64, static_assert(MAX_HEIGHT >= 2 && MAX_HEIGHT < 64,
"MAX_HEIGHT can only be in the range of [2, 64)"); "MAX_HEIGHT can only be in the range of [2, 64)");
typedef detail::SkipListNode<T> NodeType;
typedef std::unique_lock<folly::MicroSpinLock> ScopedLocker; typedef std::unique_lock<folly::MicroSpinLock> ScopedLocker;
typedef ConcurrentSkipList<T, Comp, MAX_HEIGHT> SkipListType; typedef ConcurrentSkipList<T, Comp, MAX_HEIGHT> SkipListType;
public: public:
typedef detail::SkipListNode<T> NodeType;
typedef T value_type; typedef T value_type;
typedef T key_type; typedef T key_type;
...@@ -170,6 +170,12 @@ class ConcurrentSkipList { ...@@ -170,6 +170,12 @@ class ConcurrentSkipList {
return boost::shared_ptr<SkipListType>(new SkipListType(height)); return boost::shared_ptr<SkipListType>(new SkipListType(height));
} }
// create a unique_ptr skiplist object with initial head height.
static std::unique_ptr<SkipListType> createRawInstance(int height=1) {
return std::unique_ptr<SkipListType>(new SkipListType(height));
}
//=================================================================== //===================================================================
// Below are implementation details. // Below are implementation details.
// Please see ConcurrentSkipList::Accessor for stdlib-like APIs. // Please see ConcurrentSkipList::Accessor for stdlib-like APIs.
......
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