Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 36 additions & 92 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,129 +30,60 @@
// The exact meaning of each argument depends on the benchmark, allocator, and size components used.
// Refer to the 'argsName()' function in each component to find detailed descriptions of these arguments.

static void default_alloc_fix_size(benchmark::internal::Benchmark *benchmark) {
benchmark->Args({10000, 0, 4096});
benchmark->Args({10000, 100000, 4096});
static void multithreaded(benchmark::internal::Benchmark *benchmark) {
benchmark->Threads(4);
benchmark->Threads(1);
}

static void
default_alloc_uniform_size(benchmark::internal::Benchmark *benchmark) {
benchmark->Args({10000, 0, 8, 64 * 1024, 8});
benchmark->Threads(4);
benchmark->Threads(1);
}

UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, glibc_fix, fixed_alloc_size,
glibc_malloc);

UMF_BENCHMARK_REGISTER_F(alloc_benchmark, glibc_fix)
->Apply(&default_alloc_fix_size);

UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, glibc_uniform,
uniform_alloc_size, glibc_malloc);
UMF_BENCHMARK_REGISTER_F(alloc_benchmark, glibc_uniform)
->Apply(&default_alloc_uniform_size);

UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, os_provider, fixed_alloc_size,
provider_allocator<os_provider>);
UMF_BENCHMARK_REGISTER_F(alloc_benchmark, os_provider)
->Apply(&default_alloc_fix_size);

UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, proxy_pool, fixed_alloc_size,
pool_allocator<proxy_pool<os_provider>>);

UMF_BENCHMARK_REGISTER_F(alloc_benchmark, proxy_pool)
->Apply(&default_alloc_fix_size);

UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, disjoint_pool_fix,
fixed_alloc_size,
pool_allocator<disjoint_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(alloc_benchmark, disjoint_pool_fix)
->Apply(&default_alloc_fix_size);

// TODO: debug why this crashes
/*UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, disjoint_pool_uniform,
uniform_alloc_size,
pool_allocator<disjoint_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(alloc_benchmark, disjoint_pool_uniform)
->Apply(&default_alloc_uniform_size);
*/

#ifdef UMF_POOL_JEMALLOC_ENABLED
UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, jemalloc_pool_fix,
fixed_alloc_size,
pool_allocator<jemalloc_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(alloc_benchmark, jemalloc_pool_fix)
->Apply(&default_alloc_fix_size);

UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, jemalloc_pool_uniform,
uniform_alloc_size,
pool_allocator<jemalloc_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(alloc_benchmark, jemalloc_pool_uniform)
->Apply(&default_alloc_uniform_size);

#endif
#ifdef UMF_POOL_SCALABLE_ENABLED
UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, scalable_pool_fix,
fixed_alloc_size,
pool_allocator<scalable_pool<os_provider>>);

UMF_BENCHMARK_REGISTER_F(alloc_benchmark, scalable_pool_fix)
->Apply(&default_alloc_fix_size);

UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, scalable_pool_uniform,
uniform_alloc_size,
pool_allocator<scalable_pool<os_provider>>);

UMF_BENCHMARK_REGISTER_F(alloc_benchmark, scalable_pool_uniform)
->Apply(&default_alloc_uniform_size);
#endif
// Multiple allocs/free
static void
default_multiple_alloc_fix_size(benchmark::internal::Benchmark *benchmark) {
benchmark->Args({10000, 4096});
benchmark->Threads(4);
benchmark->Threads(1);
benchmark->Args({10000, 1, 4096});
benchmark->Iterations(500000);
}

static void
default_multiple_alloc_uniform_size(benchmark::internal::Benchmark *benchmark) {
benchmark->Args({10000, 8, 64 * 1024, 8});
benchmark->Threads(4);
benchmark->Threads(1);
benchmark->Args({10000, 1, 8, 4096, 8});
benchmark->Args({10000, 1, 8, 128, 8});
benchmark->Iterations(500000);
}

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, glibc_fix,
fixed_alloc_size, glibc_malloc);

UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, glibc_fix)
->Apply(&default_multiple_alloc_fix_size);
->Apply(&default_multiple_alloc_fix_size)
->Apply(&multithreaded);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, glibc_uniform,
uniform_alloc_size, glibc_malloc);
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, glibc_uniform)
->Apply(&default_multiple_alloc_uniform_size);
->Apply(&default_multiple_alloc_uniform_size)
->Apply(&multithreaded);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, proxy_pool,
fixed_alloc_size,
pool_allocator<proxy_pool<os_provider>>);

UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, proxy_pool)
->Apply(&default_multiple_alloc_fix_size);
->Apply(&default_multiple_alloc_fix_size)
// reduce iterations, as this benchmark is slower than others
->Iterations(50000);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, os_provider,
fixed_alloc_size,
provider_allocator<os_provider>);
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, os_provider)
->Apply(&default_multiple_alloc_fix_size);
->Apply(&default_multiple_alloc_fix_size)
// reduce iterations, as this benchmark is slower than others
->Iterations(50000);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, disjoint_pool_fix,
fixed_alloc_size,
pool_allocator<disjoint_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, disjoint_pool_fix)
->Apply(&default_multiple_alloc_fix_size);
->Apply(&default_multiple_alloc_fix_size)
->Apply(&multithreaded);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark,
disjoint_pool_uniform, uniform_alloc_size,
Expand All @@ -165,13 +96,15 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, jemalloc_pool_fix,
fixed_alloc_size,
pool_allocator<jemalloc_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, jemalloc_pool_fix)
->Apply(&default_multiple_alloc_fix_size);
->Apply(&default_multiple_alloc_fix_size)
->Apply(&multithreaded);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark,
jemalloc_pool_uniform, uniform_alloc_size,
pool_allocator<jemalloc_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, jemalloc_pool_uniform)
->Apply(&default_multiple_alloc_uniform_size);
->Apply(&default_multiple_alloc_uniform_size)
->Apply(&multithreaded);

#endif

Expand All @@ -181,14 +114,25 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, scalable_pool_fix,
pool_allocator<scalable_pool<os_provider>>);

UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, scalable_pool_fix)
->Apply(&default_multiple_alloc_fix_size);
->Apply(&default_multiple_alloc_fix_size)
->Apply(&multithreaded);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark,
scalable_pool_uniform, uniform_alloc_size,
pool_allocator<scalable_pool<os_provider>>);

UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, scalable_pool_uniform)
->Apply(&default_multiple_alloc_uniform_size);
->Apply(&default_multiple_alloc_uniform_size)
->Apply(&multithreaded);

#endif
BENCHMARK_MAIN();

//BENCHMARK_MAIN();
int main(int argc, char **argv) {
if (initAffinityMask()) {
return -1;
}
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
benchmark::Shutdown();
}
Loading
Loading