Fix DynamicBloomTest.concurrent_with_perf to pass TSAN

Summary: TSAN fails on DynamicBloomTest.concurrent_with_perf. This change fixes it. Not sure why though.

Test Plan: Run the test with TSAN and make sure no warning shown.

Reviewers: yhchiang, IslamAbdelRahman, anthony, ngbronson, rven

Reviewed By: rven

Subscribers: rven, leveldb, dhruba

Differential Revision: https://reviews.facebook.net/D52383
This commit is contained in:
sdong 2015-12-29 11:04:40 -08:00
parent 63ddb783db
commit c9e2490bc6
1 changed files with 3 additions and 6 deletions

View File

@ -255,16 +255,13 @@ TEST_F(DynamicBloomTest, concurrent_with_perf) {
timer.Start(); timer.Start();
auto adder = [&](size_t t) { std::function<void(size_t)> adder = [&](size_t t) {
for (uint64_t i = 1 + t; i <= num_keys; i += num_threads) { for (uint64_t i = 1 + t; i <= num_keys; i += num_threads) {
std_bloom.AddConcurrently( std_bloom.AddConcurrently(
Slice(reinterpret_cast<const char*>(&i), 8)); Slice(reinterpret_cast<const char*>(&i), 8));
} }
}; };
for (size_t t = 0; t < num_threads; ++t) { for (size_t t = 0; t < num_threads; ++t) {
// TSAN currently complains of a race between an allocation
// made bythis race and the eventual shutdown of the thread.
// It is a false positive.
threads.emplace_back(adder, t); threads.emplace_back(adder, t);
} }
while (threads.size() > 0) { while (threads.size() > 0) {
@ -279,7 +276,7 @@ TEST_F(DynamicBloomTest, concurrent_with_perf) {
timer.Start(); timer.Start();
auto hitter = [&](size_t t) { std::function<void(size_t)> hitter = [&](size_t t) {
for (uint64_t i = 1 + t; i <= num_keys; i += num_threads) { for (uint64_t i = 1 + t; i <= num_keys; i += num_threads) {
bool f = bool f =
std_bloom.MayContain(Slice(reinterpret_cast<const char*>(&i), 8)); std_bloom.MayContain(Slice(reinterpret_cast<const char*>(&i), 8));
@ -302,7 +299,7 @@ TEST_F(DynamicBloomTest, concurrent_with_perf) {
timer.Start(); timer.Start();
std::atomic<uint32_t> false_positives(0); std::atomic<uint32_t> false_positives(0);
auto misser = [&](size_t t) { std::function<void(size_t)> misser = [&](size_t t) {
for (uint64_t i = num_keys + 1 + t; i <= 2 * num_keys; for (uint64_t i = num_keys + 1 + t; i <= 2 * num_keys;
i += num_threads) { i += num_threads) {
bool f = bool f =