Commit 5b5e5909 authored by Nicholas Ormrod's avatar Nicholas Ormrod Committed by Facebook GitHub Bot

Fix timing-out ConcurrentAdd test

Summary:
This test regularly times out under load.

I made a benchmark diff (prior to this in the stack, but not to be landed) which confirms (a) that the slowness of this test is due to spawning excessively-many threads, and (b) that the performance of ConcurrentSkipList doesn't unduly degrade with excessively-many threads. Conclusion: it is safe to simplify these tests.

To simplify the test, I ratcheted down the number of threads, but also bumped the number of iterations. Much more work is being done (so this test should retain its race-condition-hunting properties), but the time spent is much less, even when the system is under load.

Reviewed By: yfeldblum

Differential Revision: D33269899

fbshipit-source-id: 9f7a0ec5f3c1077c91e5d09c89f3752d552a6320
parent ec7f9f6f
......@@ -300,15 +300,16 @@ TEST(ConcurrentSkipList, TestMovableData) {
accessor.find(std::unique_ptr<int>(new int(N))) == accessor.end());
}
void testConcurrentAdd(int numThreads) {
TEST(ConcurrentSkipList, ConcurrentAdd) {
int numThreads = 100;
auto skipList(SkipListType::create(kHeadHeight));
vector<std::thread> threads;
vector<SetType> verifiers(numThreads);
try {
for (int i = 0; i < numThreads; ++i) {
threads.push_back(
std::thread(&randomAdding, 100, skipList, &verifiers[i], kMaxValue));
threads.push_back(std::thread(
&randomAdding, 1000000, skipList, &verifiers[i], kMaxValue));
}
} catch (const std::system_error& e) {
LOG(WARNING) << "Caught " << exceptionStr(e) << ": could only create "
......@@ -323,15 +324,6 @@ void testConcurrentAdd(int numThreads) {
verifyEqual(skipList, all);
}
TEST(ConcurrentSkipList, ConcurrentAdd) {
// test it many times
// TSAN has a thread limit around 8k.
auto maxNumThreads = folly::kIsSanitizeThread ? 8000 : 10000;
for (int numThreads = 10; numThreads < maxNumThreads; numThreads += 1000) {
testConcurrentAdd(numThreads);
}
}
void testConcurrentRemoval(int numThreads, int maxValue) {
auto skipList = SkipListType::create(kHeadHeight);
for (int i = 0; i < maxValue; ++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