Commit 3ea63e0b authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

hazptr: Add microbenchmark for unused tagged obj batch

Summary:
Adds a microbenchmark for the lifetime of an unused tagged hazptr_obj_batch in the presence of unrelated objects in the domain's tagged list.

This diff also makes the calculation of the number of operations and the scalability measure for the cleanup microbenchmark more consistent with those for the other microbenchmarks.

Reviewed By: davidtgoldblatt

Differential Revision: D17416088

fbshipit-source-id: b59fd1b48114d591da5d9432df7910d940683006
parent cc773968
......@@ -1404,7 +1404,7 @@ uint64_t cleanup_bench(std::string name, int nthreads) {
auto init = [] {};
auto fn = [&](int) {
hazptr_holder<std::atomic> hptr;
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < ops / 1000; i++) {
hazptr_cleanup();
}
};
......@@ -1414,6 +1414,30 @@ uint64_t cleanup_bench(std::string name, int nthreads) {
return bench(name, ops, repFn);
}
uint64_t batch_bench(std::string name, int nthreads) {
struct Foo : public hazptr_obj_base<Foo> {};
// Push unrelated objects into the domain tagged list
hazptr_obj_batch batch;
for (int i = 0; i < 999; ++i) {
auto p = new Foo;
p->set_batch_tag(&batch);
p->retire();
}
auto repFn = [&] {
auto init = [] {};
auto fn = [&](int tid) {
for (int j = tid; j < ops; j += nthreads) {
hazptr_obj_batch b;
b.shutdown_and_reclaim();
hazptr_cleanup_batch_tag<std::atomic>(&b);
}
};
auto endFn = [] {};
return run_once(nthreads, init, fn, endFn);
};
return bench(name, ops, repFn);
}
const int nthr[] = {1, 10};
const int sizes[] = {10, 20};
......@@ -1448,8 +1472,10 @@ void benches() {
std::cout << j << "-item list protect all ";
list_protect_all_bench("", i, j);
}
std::cout << "hazptr_cleanup ";
std::cout << "1/1000 hazptr_cleanup ";
cleanup_bench("", i);
std::cout << "Life cycle of unused tagged obj batch ";
batch_bench("", i);
}
}
......@@ -1479,7 +1505,8 @@ allocate/retire/reclaim object 70 ns 68 ns 67 ns
20-item list hand-over-hand 48 ns 43 ns 41 ns
20-item list protect all - own hazptr 28 ns 28 ns 28 ns
20-item list protect all 31 ns 29 ns 29 ns
hazptr_cleanup 2 ns 1 ns 1 ns
1/1000 hazptr_cleanup 2 ns 1 ns 1 ns
Life cycle of unused tagged obj batch 1577 ns 1547 ns 1511 ns
================================ 10 threads ================================
10x construct/destruct hazptr_holder 11 ns 8 ns 8 ns
10x construct/destruct hazptr_array<1> 8 ns 7 ns 7 ns
......@@ -1497,5 +1524,6 @@ allocate/retire/reclaim object 20 ns 17 ns 16 ns
20-item list hand-over-hand 6 ns 6 ns 6 ns
20-item list protect all - own hazptr 4 ns 4 ns 4 ns
20-item list protect all 5 ns 4 ns 4 ns
hazptr_cleanup 119 ns 113 ns 97 ns
*/
1/1000 hazptr_cleanup 119 ns 113 ns 97 ns
Life cycle of unused tagged obj batch 1985 ns 1918 ns 1853 ns
*/
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