Skip to content

Add TBB pool manager to benchmark #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2023
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
19 changes: 16 additions & 3 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y cmake libnuma-dev libjemalloc-dev
sudo apt-get install -y cmake libnuma-dev libjemalloc-dev libtbb-dev

- name: Configure build
run: >
Expand All @@ -35,12 +35,25 @@ jobs:
-DUMF_DEVELOPER_MODE=OFF
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=OFF
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_ENABLE_POOL_TRACKING=OFF

- name: Build UMF
run: cmake --build ${{github.workspace}}/build -j $(nproc)

- name: Run benchmarks
working-directory: ${{github.workspace}}/build
run: ./benchmark/ubench 2>/dev/null
# The benchmark of TBB pool manager run on CI very often fails
# with the "confidence interval exceeds maximum permitted 2.5%" error,
# so do not treat that as an error, but succeed in this case.
run: |
export LOG=/tmp/ubench.log
if ! ./benchmark/ubench 2>/dev/null > $LOG; then \
cat $LOG; \
if ! grep -q -e "exceeds maximum permitted 2.5" $LOG; then \
echo "[ FAILED ] The CI benchmark job FAILED."; \
exit 1; \
fi; \
fi
cat $LOG
echo "[ PASSED ] The CI benchmark job PASSED."
8 changes: 8 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} jemalloc_pool)
endif()

if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} scalable_pool)
endif()

add_executable(ubench ubench.c)

add_dependencies(ubench
Expand All @@ -35,3 +39,7 @@ endif()
if (UMF_BUILD_LIBUMF_POOL_JEMALLOC)
target_compile_definitions(ubench PRIVATE UMF_BUILD_LIBUMF_POOL_JEMALLOC=1)
endif()

if (UMF_BUILD_LIBUMF_POOL_SCALABLE)
target_compile_definitions(ubench PRIVATE UMF_BUILD_LIBUMF_POOL_SCALABLE=1)
endif()
45 changes: 43 additions & 2 deletions benchmark/ubench.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <umf/pools/pool_jemalloc.h>
#endif

#ifdef UMF_BUILD_LIBUMF_POOL_SCALABLE
#include <umf/pools/pool_scalable.h>
#endif

#include <stdbool.h>
#include <unistd.h>

Expand Down Expand Up @@ -154,7 +158,8 @@ UBENCH_EX(simple, os_memory_provider) {
}

#if (defined UMF_BUILD_LIBUMF_POOL_DISJOINT) || \
(defined UMF_BUILD_LIBUMF_POOL_JEMALLOC)
(defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) || \
(defined UMF_BUILD_LIBUMF_POOL_SCALABLE)

static void *w_umfPoolMalloc(void *provider, size_t size, size_t alignment) {
umf_memory_pool_handle_t hPool = (umf_memory_pool_handle_t)provider;
Expand All @@ -169,7 +174,7 @@ static void w_umfPoolFree(void *provider, void *ptr, size_t size) {
exit(-1);
}
}
#endif /* (defined UMF_BUILD_LIBUMF_POOL_DISJOINT) || (defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) */
#endif /* (defined UMF_BUILD_LIBUMF_POOL_DISJOINT) || (defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) || (defined UMF_BUILD_LIBUMF_POOL_SCALABLE) */

#ifdef UMF_BUILD_LIBUMF_POOL_DISJOINT
////////////////// DISJOINT POOL WITH OS MEMORY PROVIDER
Expand Down Expand Up @@ -251,4 +256,40 @@ UBENCH_EX(simple, jemalloc_pool_with_os_memory_provider) {
}
#endif /* UMF_BUILD_LIBUMF_POOL_JEMALLOC */

#ifdef UMF_BUILD_LIBUMF_POOL_SCALABLE
////////////////// SCALABLE (TBB) POOL WITH OS MEMORY PROVIDER

UBENCH_EX(simple, scalable_pool_with_os_memory_provider) {
alloc_t *array = alloc_array(N_ITERATIONS);

enum umf_result_t umf_result;
umf_memory_provider_handle_t os_memory_provider = NULL;
umf_result = umfMemoryProviderCreate(&UMF_OS_MEMORY_PROVIDER_OPS,
&UMF_OS_MEMORY_PROVIDER_PARAMS,
&os_memory_provider);
if (umf_result != UMF_RESULT_SUCCESS) {
exit(-1);
}

umf_memory_pool_handle_t scalable_pool;
umf_result = umfPoolCreate(&UMF_SCALABLE_POOL_OPS, os_memory_provider, NULL,
&scalable_pool);
if (umf_result != UMF_RESULT_SUCCESS) {
exit(-1);
}

do_benchmark(array, N_ITERATIONS, w_umfPoolMalloc, w_umfPoolFree,
scalable_pool); // WARMUP

UBENCH_DO_BENCHMARK() {
do_benchmark(array, N_ITERATIONS, w_umfPoolMalloc, w_umfPoolFree,
scalable_pool);
}

umfPoolDestroy(scalable_pool);
umfMemoryProviderDestroy(os_memory_provider);
free(array);
}
#endif /* UMF_BUILD_LIBUMF_POOL_SCALABLE */

UBENCH_MAIN();