Commit 6d02e2b5 authored by Dave Watson's avatar Dave Watson Committed by Facebook Github Bot

Remove hazptr_cleanup from ConcurrentHashMap

Summary: Causing perf issues.  Users must add explicitly to tests or other use cases.

Differential Revision: D8162835

fbshipit-source-id: 7095064209ced870768552307675dc1ebbf68bdc
parent e132960c
...@@ -153,6 +153,11 @@ class ConcurrentHashMap { ...@@ -153,6 +153,11 @@ class ConcurrentHashMap {
return *this; return *this;
} }
/* Note that some objects stored in ConcurrentHashMap may outlive the
* ConcurrentHashMap's destructor, if you need immediate cleanup, call
* hazptr_cleanup(), which guarantees all objects are destructed after
* it completes.
*/
~ConcurrentHashMap() { ~ConcurrentHashMap() {
for (uint64_t i = 0; i < NumShards; i++) { for (uint64_t i = 0; i < NumShards; i++) {
auto seg = segments_[i].load(std::memory_order_relaxed); auto seg = segments_[i].load(std::memory_order_relaxed);
...@@ -161,7 +166,6 @@ class ConcurrentHashMap { ...@@ -161,7 +166,6 @@ class ConcurrentHashMap {
Allocator().deallocate((uint8_t*)seg, sizeof(SegmentT)); Allocator().deallocate((uint8_t*)seg, sizeof(SegmentT));
} }
} }
folly::hazptr::hazptr_cleanup(folly::hazptr::default_hazptr_domain());
} }
bool empty() const noexcept { bool empty() const noexcept {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <folly/test/DeterministicSchedule.h> #include <folly/test/DeterministicSchedule.h>
using namespace folly::test; using namespace folly::test;
using namespace folly::hazptr;
using namespace folly; using namespace folly;
using namespace std; using namespace std;
...@@ -622,6 +623,8 @@ TEST(ConcurrentHashMap, DeletionWithErase) { ...@@ -622,6 +623,8 @@ TEST(ConcurrentHashMap, DeletionWithErase) {
map.erase(0); map.erase(0);
} }
hazptr_cleanup();
EXPECT_TRUE(del); EXPECT_TRUE(del);
} }
...@@ -636,6 +639,8 @@ TEST(ConcurrentHashMap, DeletionWithIterator) { ...@@ -636,6 +639,8 @@ TEST(ConcurrentHashMap, DeletionWithIterator) {
map.erase(it); map.erase(it);
} }
hazptr_cleanup();
EXPECT_TRUE(del); EXPECT_TRUE(del);
} }
...@@ -678,6 +683,8 @@ TEST(ConcurrentHashMap, DeletionAssigned) { ...@@ -678,6 +683,8 @@ TEST(ConcurrentHashMap, DeletionAssigned) {
map.insert_or_assign(0, std::make_shared<Wrapper>(del2)); map.insert_or_assign(0, std::make_shared<Wrapper>(del2));
} }
hazptr_cleanup();
EXPECT_TRUE(del1); EXPECT_TRUE(del1);
EXPECT_TRUE(del2); EXPECT_TRUE(del2);
} }
...@@ -693,6 +700,8 @@ TEST(ConcurrentHashMap, DeletionMultipleMaps) { ...@@ -693,6 +700,8 @@ TEST(ConcurrentHashMap, DeletionMultipleMaps) {
map2.insert(0, std::make_shared<Wrapper>(del2)); map2.insert(0, std::make_shared<Wrapper>(del2));
} }
hazptr_cleanup();
EXPECT_TRUE(del1); EXPECT_TRUE(del1);
EXPECT_TRUE(del2); EXPECT_TRUE(del2);
} }
......
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