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
main
Mark Callaghan 3 years ago committed by Facebook GitHub Bot
parent e2cb9aa27c
commit 37de4e1d08
  1. 5
      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]);

Loading…
Cancel
Save