From 37de4e1d084349db225c26101737c6e73b7595bd Mon Sep 17 00:00:00 2001 From: Mark Callaghan Date: Fri, 25 Mar 2022 15:30:28 -0700 Subject: [PATCH] Correctly set ThreadState::tid (#9757) Summary: Fixes a bug introduced by me in https://github.com/facebook/rocksdb/pull/9733 That PR added a counter so that the per-thread seeds in ThreadState would be unique even when --benchmarks had more than one test. But it incorrectly used this counter as the value for ThreadState::tid as well. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9757 Test Plan: Confirm that unexpectedly good QPS results on the regression tests return to normal with this fix. I have confirmed that the QPS increase starts with the PR 9733 diff. Reviewed By: jay-zhuang Differential Revision: D35149303 Pulled By: mdcallag fbshipit-source-id: dee5cc36b7faaba6c3be6d6a253d3c2eaad72864 --- tools/db_bench_tool.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index fb2270adb..95cc008be 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -2427,7 +2427,8 @@ struct ThreadState { Stats stats; SharedState* shared; - explicit ThreadState(int index) : tid(index), rand(seed_base + index) {} + explicit ThreadState(int index, int my_seed) + : tid(index), rand(seed_base + my_seed) {} }; class Duration { @@ -3663,7 +3664,7 @@ class Benchmark { arg[i].method = method; arg[i].shared = &shared; total_thread_count_++; - arg[i].thread = new ThreadState(total_thread_count_); + arg[i].thread = new ThreadState(i, total_thread_count_); arg[i].thread->stats.SetReporterAgent(reporter_agent.get()); arg[i].thread->shared = &shared; FLAGS_env->StartThread(ThreadBody, &arg[i]);