Commit 36f840db authored by Dave Watson's avatar Dave Watson Committed by Facebook Github Bot

Increase refcount size

Summary:
The refcounting logic is correct, however, decreasing the next node's
refcount only happens in ~NodeT, after going through hazptr bulkReclaim.

The current default for bulkReclaim is 1k, which exceeds the value of
refcount uint8_t.  Increase size to uint16_t so that we don't wrap refcount
before bulkReclaim calls the node destructors.

Reviewed By: magedm

Differential Revision: D6900530

fbshipit-source-id: 9b2530dc6cd0609b4795b909fd46aeffbb1ae821
parent 8e8bfe9c
...@@ -156,7 +156,7 @@ class NodeT : public folly::hazptr::hazptr_obj_base< ...@@ -156,7 +156,7 @@ class NodeT : public folly::hazptr::hazptr_obj_base<
private: private:
ValueHolder<KeyType, ValueType, Allocator> item_; ValueHolder<KeyType, ValueType, Allocator> item_;
Atom<uint8_t> refcount_{1}; Atom<uint16_t> refcount_{1};
}; };
} // namespace concurrenthashmap } // namespace concurrenthashmap
......
...@@ -547,3 +547,25 @@ TEST(ConcurrentHashMap, assignStressTest) { ...@@ -547,3 +547,25 @@ TEST(ConcurrentHashMap, assignStressTest) {
join; join;
} }
} }
TEST(ConcurrentHashMap, RefcountTest) {
struct badhash {
size_t operator()(uint64_t) const {
return 0;
}
};
ConcurrentHashMap<
uint64_t,
uint64_t,
badhash,
std::equal_to<uint64_t>,
std::allocator<uint8_t>,
0>
foomap(3);
foomap.insert(0, 0);
foomap.insert(1, 1);
foomap.insert(2, 2);
for (int32_t i = 0; i < 300; ++i) {
foomap.insert_or_assign(1, i);
}
}
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