Commit 2ba9c401 authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

Back out "hazptr: Support obj batch bypass to domain"

Summary: Original commit changeset: a1af88dfa1b6

Reviewed By: d4l3k

Differential Revision: D18535282

fbshipit-source-id: 16da3084a519f978bf33f197ab7f937b61bb9d07
parent 789882d5
......@@ -299,17 +299,12 @@ class hazptr_obj_batch {
SharedList l_;
Atom<int> count_;
bool active_;
bool bypass_to_domain_;
Atom<bool> pushed_to_domain_tagged_;
public:
/** Constructor */
hazptr_obj_batch() noexcept
: l_(),
count_(0),
active_(true),
bypass_to_domain_(false),
pushed_to_domain_tagged_{false} {}
: l_(), count_(0), active_(true), pushed_to_domain_tagged_{false} {}
/** Not copyable or moveable */
hazptr_obj_batch(const hazptr_obj_batch& o) = delete;
......@@ -343,11 +338,6 @@ class hazptr_obj_batch {
DCHECK(l_.empty());
}
/** set_bypass_to_domain : Not thread-safe */
void set_bypass_to_domain() {
bypass_to_domain_ = true;
}
private:
friend class hazptr_obj<Atom>;
......@@ -370,19 +360,13 @@ class hazptr_obj_batch {
/** push_obj */
void push_obj(Obj* obj) {
obj->set_next(nullptr);
if (!active_ || !default_hazptr_domain_alive<Atom>()) {
reclaim_list(obj);
} else if (bypass_to_domain_) {
if (obj->tagged()) {
pushed_to_domain_tagged_.store(true, std::memory_order_relaxed);
}
hazptr_obj_list<Atom> l(obj, obj, 1);
hazptr_domain_push_list<Atom>(l);
} else {
if (active_ && default_hazptr_domain_alive<Atom>()) {
l_.push(obj);
inc_count();
check_threshold_push();
} else {
obj->set_next(nullptr);
reclaim_list(obj);
}
}
......@@ -401,6 +385,9 @@ class hazptr_obj_batch {
/** check_threshold_push */
void check_threshold_push() {
if (!default_hazptr_domain_alive<Atom>()) {
return;
}
auto c = count();
while (c >= kThreshold) {
if (cas_count(c, 0)) {
......
......@@ -814,7 +814,6 @@ template <template <typename> class Atom = std::atomic>
void batch_test() {
int num = 10001;
using NodeT = Node<Atom>;
// untagged
c_.clear();
{
hazptr_obj_batch<Atom> batch;
......@@ -828,28 +827,11 @@ void batch_test() {
DSched::join(thr);
}
ASSERT_EQ(c_.ctors(), num);
// ASSERT_GT(c_.dtors(), 0);
hazptr_cleanup<Atom>();
ASSERT_EQ(c_.dtors(), num);
// tagged
c_.clear();
{
hazptr_obj_batch<Atom> batch;
auto thr = DSched::thread([&]() {
for (int i = 0; i < num; ++i) {
auto p = new NodeT;
p->set_batch_tag(&batch);
p->retire();
}
});
DSched::join(thr);
}
ASSERT_EQ(c_.ctors(), num);
ASSERT_EQ(c_.dtors(), num);
// bypass to domain
c_.clear();
{
hazptr_obj_batch<Atom> batch;
batch.set_bypass_to_domain();
auto thr = DSched::thread([&]() {
for (int i = 0; i < num; ++i) {
auto p = new NodeT;
......@@ -860,7 +842,8 @@ void batch_test() {
DSched::join(thr);
}
ASSERT_EQ(c_.ctors(), num);
ASSERT_EQ(c_.dtors(), num);
ASSERT_GT(c_.dtors(), 0);
hazptr_cleanup<Atom>();
}
template <template <typename> class Atom = std::atomic>
......
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