Skip to content

Commit 1387832

Browse files
Merge pull request #1205 from lplewa/disjoint_thread
reduce number of benchmark threads with disjoint pool
2 parents d4c2672 + fa7a6ac commit 1387832

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

benchmark/benchmark.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
// The exact meaning of each argument depends on the benchmark, allocator, and size components used.
3131
// Refer to the 'argsName()' function in each component to find detailed descriptions of these arguments.
3232

33+
template <size_t max_threads = 12>
3334
static void multithreaded(benchmark::internal::Benchmark *benchmark) {
34-
benchmark->Threads(12);
35-
benchmark->Threads(8);
36-
benchmark->Threads(4);
3735
benchmark->Threads(1);
36+
benchmark->DenseThreadRange(4, max_threads, 4);
3837
}
3938

4039
static void singlethreaded(benchmark::internal::Benchmark *benchmark) {
@@ -91,14 +90,16 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, disjoint_pool_fix,
9190
pool_allocator<disjoint_pool<os_provider>>);
9291
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, disjoint_pool_fix)
9392
->Apply(&default_multiple_alloc_fix_size)
94-
->Apply(&multithreaded);
93+
// Limit benchmarks to 4 threads, as the disjoint pool scales poorly with higher thread counts.
94+
->Apply(&multithreaded<4>);
9595

9696
UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark,
9797
disjoint_pool_uniform, uniform_alloc_size,
9898
pool_allocator<disjoint_pool<os_provider>>);
9999
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, disjoint_pool_uniform)
100100
->Apply(&default_multiple_alloc_uniform_size)
101-
->Apply(&multithreaded);
101+
// Limit benchmarks to 4 threads, as the disjoint pool scales poorly with higher thread counts.
102+
->Apply(&multithreaded<4>);
102103

103104
#ifdef UMF_POOL_JEMALLOC_ENABLED
104105
UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, jemalloc_pool_fix,

0 commit comments

Comments
 (0)