From 98b1a7710e5aaf3f1b7e6ba335079acf4379f01d Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 11 Jul 2022 14:47:55 -0700 Subject: [PATCH] Changed num_threads based on slowness factor for xSAN (#30240) * Changed num_threads * Update by review * Update by review --- test/cpp/end2end/thread_stress_test.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index 67c9d6d1346..9be625fadbd 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -43,7 +43,13 @@ using grpc::testing::EchoRequest; using grpc::testing::EchoResponse; +#if defined(__APPLE__) +// Use less # of threads on Mac because its test machines are less powerful +// to finish the test on time. (context: b/185231823) +const int kNumThreads = 100; // Number of threads +#else const int kNumThreads = 300; // Number of threads +#endif const int kNumAsyncSendThreads = 2; const int kNumAsyncReceiveThreads = 50; const int kNumAsyncServerThreads = 50; @@ -314,12 +320,15 @@ TYPED_TEST(End2endTest, ThreadStress) { std::vector threads; gpr_atm errors; gpr_atm_rel_store(&errors, static_cast(0)); - threads.reserve(kNumThreads); - for (int i = 0; i < kNumThreads; ++i) { + int num_threads = kNumThreads / grpc_test_slowdown_factor(); + // The number of threads should be > 10 to be able to catch errors + ASSERT_GT(num_threads, 10); + threads.reserve(num_threads); + for (int i = 0; i < num_threads; ++i) { threads.emplace_back(SendRpc, this->common_.GetStub(), kNumRpcs, this->common_.AllowExhaustion(), &errors); } - for (int i = 0; i < kNumThreads; ++i) { + for (int i = 0; i < num_threads; ++i) { threads[i].join(); } uint64_t error_cnt = static_cast(gpr_atm_no_barrier_load(&errors));