}
class WebCacheConcurrencyTest : public WebCacheTest {
+ protected:
+ // 4x oversubscription is enough to race the threads. The original *100
+ // (3200 on CI) made exclusive-lock tests O(N^2) and timed out on Windows.
+ static unsigned stress_thread_count() {
+ return std::max(std::thread::hardware_concurrency() * 4, 32u);
+ }
+
void TearDown() override {
if (_uut->perf() != nullptr) {
JSONFormatter f(true);
TEST_F(WebCacheConcurrencyTest, BasicAddSame) {
reset_cache_system_mode(100);
- const auto num_threads =
- std::max(std::thread::hardware_concurrency() * 100, 100U);
+ const auto num_threads = stress_thread_count();
std::vector<std::thread> threads;
for (size_t i = 0; i < num_threads; ++i) {
threads.emplace_back([&]() {
TEST_F(WebCacheConcurrencyTest, BasicAddUnique) {
reset_cache_system_mode(100);
- const auto num_threads =
- std::max(std::thread::hardware_concurrency() * 100, 100U);
+ const auto num_threads = stress_thread_count();
std::vector<std::thread> threads;
for (size_t i = 0; i < num_threads; ++i) {
threads.emplace_back([&]() {
webcache::WebCache<std::string, CacheValue> cache(
_cct.get(), "test_web_cache", 100);
std::atomic_int fetches = 0;
- const auto num_threads =
- std::max(std::thread::hardware_concurrency() * 100, 100U);
+ const auto num_threads = stress_thread_count();
std::vector<std::thread> threads;
for (size_t i = 0; i < num_threads; ++i) {
threads.emplace_back([&]() {
webcache::WebCache<std::string, CacheValue> cache(
_cct.get(), "test_web_cache", 100);
std::atomic_int fetches = 0;
- const auto num_threads =
- std::max(std::thread::hardware_concurrency() * 100, 100U);
+ const auto num_threads = stress_thread_count();
std::vector<std::thread> threads;
for (size_t i = 0; i < num_threads; ++i) {
threads.emplace_back([&]() {