What's the best practice for user-managed multithreading benchmarks?

178 views
Skip to first unread message

Jiahao Li

unread,
Jul 21, 2020, 2:31:46 AM7/21/20
to benchmark-discuss
Hi,

I'm using benchmark to test SPDK performance, and need to manage threads myself, so that they can be bound to specific cores. Currently, I'm using an atomic counter to synchronize between master thread and worker threads, and run the waiting loop in master thread:
for (auto _ : state) {
  while (iterations ==  counter);
  iterations++;
}
worker threads increment counter each time when an operation is done.
This approach works, but it seems inter-thread synchronization is a huge overhead. Comparing to un-threaded benchmark, threaded benchmark shows 30%+ slower performance.

I wonder if there are better approaches to run benchmark in this situation.

Thanks,
Jiahao Li

Dominic Hamon

unread,
Jul 21, 2020, 7:03:44 AM7/21/20
to Jiahao Li, benchmark-discuss
Do you pause the timing while waiting for synchronization? Or is synchronization something that you want to explicitly understand as part of the performance?


--
You received this message because you are subscribed to the Google Groups "benchmark-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to benchmark-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/benchmark-discuss/5ffe14ab-da4b-428c-927c-4f65bcd03dben%40googlegroups.com.

Jiahao Li

unread,
Jul 21, 2020, 7:12:52 AM7/21/20
to benchmark-discuss
The atomic counter itself is a workaround to synchronize between threads (so that state.iteration() corresponds to total actions performed by all threads). What I want to achieve is to let worker threads run for a while and summarize their overall performance.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages