diff --git a/db_stress_tool/db_stress_driver.cc b/db_stress_tool/db_stress_driver.cc index b944214ec6d..6620b1e4cdb 100644 --- a/db_stress_tool/db_stress_driver.cc +++ b/db_stress_tool/db_stress_driver.cc @@ -68,22 +68,25 @@ bool RunStressTest(StressTest* stress) { } #endif - uint32_t n = shared.GetNumThreads(); + uint32_t n = FLAGS_threads; uint64_t now = clock->NowMicros(); fprintf(stdout, "%s Initializing worker threads\n", clock->TimeToString(now / 1000000).c_str()); std::vector threads(n); for (uint32_t i = 0; i < n; i++) { + shared.IncThreads(); threads[i] = new ThreadState(i, &shared); db_stress_env->StartThread(ThreadBody, threads[i]); } ThreadState bg_thread(0, &shared); if (FLAGS_compaction_thread_pool_adjust_interval > 0) { + shared.IncBgThreads(); db_stress_env->StartThread(PoolSizeChangeThread, &bg_thread); } ThreadState continuous_verification_thread(0, &shared); if (FLAGS_continuous_verification_interval > 0) { + shared.IncBgThreads(); db_stress_env->StartThread(DbVerificationThread, &continuous_verification_thread); } diff --git a/db_stress_tool/db_stress_shared_state.h b/db_stress_tool/db_stress_shared_state.h index 1f1542f3680..d48aeb131a6 100644 --- a/db_stress_tool/db_stress_shared_state.h +++ b/db_stress_tool/db_stress_shared_state.h @@ -68,7 +68,7 @@ class SharedState { seed_(static_cast(FLAGS_seed)), max_key_(FLAGS_max_key), log2_keys_per_lock_(static_cast(FLAGS_log2_keys_per_lock)), - num_threads_(FLAGS_threads), + num_threads_(0), num_initialized_(0), num_populated_(0), vote_reopen_(0), @@ -163,14 +163,6 @@ class SharedState { ptr.reset(new port::Mutex); } } - if (FLAGS_compaction_thread_pool_adjust_interval > 0) { - ++num_bg_threads_; - fprintf(stdout, "Starting compaction_thread_pool_adjust_thread\n"); - } - if (FLAGS_continuous_verification_interval > 0) { - ++num_bg_threads_; - fprintf(stdout, "Starting continuous_verification_thread\n"); - } #ifndef NDEBUG if (FLAGS_read_fault_one_in) { SyncPoint::GetInstance()->SetCallBack("FaultInjectionIgnoreError", @@ -199,6 +191,8 @@ class SharedState { uint32_t GetNumThreads() const { return num_threads_; } + void IncThreads() { num_threads_++; } + void IncInitialized() { num_initialized_++; } void IncOperated() { num_populated_++; } @@ -317,6 +311,8 @@ class SharedState { bool ShouldStopBgThread() { return should_stop_bg_thread_; } + void IncBgThreads() { ++num_bg_threads_; } + void IncBgThreadsFinished() { ++bg_thread_finished_; } bool BgThreadsFinished() const { @@ -347,7 +343,7 @@ class SharedState { const uint32_t seed_; const int64_t max_key_; const uint32_t log2_keys_per_lock_; - const int num_threads_; + int num_threads_; long num_initialized_; long num_populated_; long vote_reopen_;