Skip to content

Commit

Permalink
tests: Simplify threading configuration
Browse files Browse the repository at this point in the history
When this test was introduced running time could vary 10x depending
on device. Reduce the number of threads to reduce threading
contention (but still keep high enough) with a hope to make running
time a bit less unpredictable.
  • Loading branch information
artem-lunarg committed Sep 24, 2024
1 parent f58cf5e commit 4429f57
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions tests/unit/sync_val_positive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,14 @@ TEST_F(PositiveSyncVal, GetSemaphoreCounterFromMultipleThreads) {
GTEST_SKIP() << "Test not supported by MockICD";
}

constexpr uint64_t max_signal_value = 15'000;
constexpr uint64_t max_signal_value = 10'000;

VkSemaphoreTypeCreateInfo semaphore_type_info = vku::InitStructHelper();
semaphore_type_info.semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE;
const VkSemaphoreCreateInfo create_info = vku::InitStructHelper(&semaphore_type_info);
vkt::Semaphore semaphore(*m_device, create_info);
vkt::Semaphore semaphore(*m_device, VK_SEMAPHORE_TYPE_TIMELINE);

std::atomic<bool> bailout{false};
m_errorMonitor->SetBailout(&bailout);

constexpr int waiter_count = 24;
constexpr int waiter_count = 12;
ThreadTimeoutHelper timeout_helper(waiter_count + 1 /* signaling thread*/);

// Start a bunch of waiter threads
Expand Down Expand Up @@ -370,22 +367,10 @@ TEST_F(PositiveSyncVal, GetSemaphoreCounterFromMultipleThreads) {
}
});

// In the regression case we expect crashes or deadlocks.
// Timeout helper will unstack CI machines in case of a deadlock.
#ifdef NDEBUG
constexpr int wait_time = 100;
#else
// Use large timeout value in case of bad CI performance.
// On Windows debug build on development machine (4 cores) takes less than 10 seconds.
// Some CI runs of debug build on Linux machine took around 60 seconds and there were
// few timeouts with 100 seconds. Use larger values to test if it's stable enough.
// Another option is to reduce thread count or iteration count for debug build.
constexpr int wait_time = 300;
#endif

if (!timeout_helper.WaitForThreads(wait_time)) {
ADD_FAILURE() << "The waiting time for the worker threads exceeded the maximum limit: " << wait_time << " seconds.";
return;
bailout.store(true);
}
for (auto &waiter : waiters) {
waiter.join();
Expand Down

0 comments on commit 4429f57

Please sign in to comment.