Skip to content

Commit 4aaf053

Browse files
committed
Add scalable (TBB) pool manager to benchmark
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent f0c40f3 commit 4aaf053

File tree

3 files changed

+67
-5
lines changed

3 files changed

+67
-5
lines changed

.github/workflows/benchmarks.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install apt packages
2121
run: |
2222
sudo apt-get update
23-
sudo apt-get install -y cmake libnuma-dev libjemalloc-dev
23+
sudo apt-get install -y cmake libnuma-dev libjemalloc-dev libtbb-dev
2424
2525
- name: Configure build
2626
run: >
@@ -35,12 +35,25 @@ jobs:
3535
-DUMF_DEVELOPER_MODE=OFF
3636
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
3737
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
38-
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=OFF
38+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
3939
-DUMF_ENABLE_POOL_TRACKING=OFF
4040
4141
- name: Build UMF
4242
run: cmake --build ${{github.workspace}}/build -j $(nproc)
4343

4444
- name: Run benchmarks
4545
working-directory: ${{github.workspace}}/build
46-
run: ./benchmark/ubench 2>/dev/null
46+
# The benchmark of TBB pool manager run on CI very often fails
47+
# with the "confidence interval exceeds maximum permitted 2.5%" error,
48+
# so do not treat that as an error, but succeed in this case.
49+
run: |
50+
export LOG=/tmp/ubench.log
51+
if ! ./benchmark/ubench 2>/dev/null > $LOG; then \
52+
cat $LOG; \
53+
if ! grep -q -e "exceeds maximum permitted 2.5" $LOG; then \
54+
echo "[ FAILED ] The CI benchmark job FAILED."; \
55+
exit 1; \
56+
fi; \
57+
fi
58+
cat $LOG
59+
echo "[ PASSED ] The CI benchmark job PASSED."

benchmark/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
1414
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} jemalloc_pool)
1515
endif()
1616

17+
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
18+
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} scalable_pool)
19+
endif()
20+
1721
add_executable(ubench ubench.c)
1822

1923
add_dependencies(ubench
@@ -35,3 +39,7 @@ endif()
3539
if (UMF_BUILD_LIBUMF_POOL_JEMALLOC)
3640
target_compile_definitions(ubench PRIVATE UMF_BUILD_LIBUMF_POOL_JEMALLOC=1)
3741
endif()
42+
43+
if (UMF_BUILD_LIBUMF_POOL_SCALABLE)
44+
target_compile_definitions(ubench PRIVATE UMF_BUILD_LIBUMF_POOL_SCALABLE=1)
45+
endif()

benchmark/ubench.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include <umf/pools/pool_jemalloc.h>
1919
#endif
2020

21+
#ifdef UMF_BUILD_LIBUMF_POOL_SCALABLE
22+
#include <umf/pools/pool_scalable.h>
23+
#endif
24+
2125
#include <stdbool.h>
2226
#include <unistd.h>
2327

@@ -154,7 +158,8 @@ UBENCH_EX(simple, os_memory_provider) {
154158
}
155159

156160
#if (defined UMF_BUILD_LIBUMF_POOL_DISJOINT) || \
157-
(defined UMF_BUILD_LIBUMF_POOL_JEMALLOC)
161+
(defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) || \
162+
(defined UMF_BUILD_LIBUMF_POOL_SCALABLE)
158163

159164
static void *w_umfPoolMalloc(void *provider, size_t size, size_t alignment) {
160165
umf_memory_pool_handle_t hPool = (umf_memory_pool_handle_t)provider;
@@ -169,7 +174,7 @@ static void w_umfPoolFree(void *provider, void *ptr, size_t size) {
169174
exit(-1);
170175
}
171176
}
172-
#endif /* (defined UMF_BUILD_LIBUMF_POOL_DISJOINT) || (defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) */
177+
#endif /* (defined UMF_BUILD_LIBUMF_POOL_DISJOINT) || (defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) || (defined UMF_BUILD_LIBUMF_POOL_SCALABLE) */
173178

174179
#ifdef UMF_BUILD_LIBUMF_POOL_DISJOINT
175180
////////////////// DISJOINT POOL WITH OS MEMORY PROVIDER
@@ -251,4 +256,40 @@ UBENCH_EX(simple, jemalloc_pool_with_os_memory_provider) {
251256
}
252257
#endif /* UMF_BUILD_LIBUMF_POOL_JEMALLOC */
253258

259+
#ifdef UMF_BUILD_LIBUMF_POOL_SCALABLE
260+
////////////////// SCALABLE (TBB) POOL WITH OS MEMORY PROVIDER
261+
262+
UBENCH_EX(simple, scalable_pool_with_os_memory_provider) {
263+
alloc_t *array = alloc_array(N_ITERATIONS);
264+
265+
enum umf_result_t umf_result;
266+
umf_memory_provider_handle_t os_memory_provider = NULL;
267+
umf_result = umfMemoryProviderCreate(&UMF_OS_MEMORY_PROVIDER_OPS,
268+
&UMF_OS_MEMORY_PROVIDER_PARAMS,
269+
&os_memory_provider);
270+
if (umf_result != UMF_RESULT_SUCCESS) {
271+
exit(-1);
272+
}
273+
274+
umf_memory_pool_handle_t scalable_pool;
275+
umf_result = umfPoolCreate(&UMF_SCALABLE_POOL_OPS, os_memory_provider, NULL,
276+
&scalable_pool);
277+
if (umf_result != UMF_RESULT_SUCCESS) {
278+
exit(-1);
279+
}
280+
281+
do_benchmark(array, N_ITERATIONS, w_umfPoolMalloc, w_umfPoolFree,
282+
scalable_pool); // WARMUP
283+
284+
UBENCH_DO_BENCHMARK() {
285+
do_benchmark(array, N_ITERATIONS, w_umfPoolMalloc, w_umfPoolFree,
286+
scalable_pool);
287+
}
288+
289+
umfPoolDestroy(scalable_pool);
290+
umfMemoryProviderDestroy(os_memory_provider);
291+
free(array);
292+
}
293+
#endif /* UMF_BUILD_LIBUMF_POOL_SCALABLE */
294+
254295
UBENCH_MAIN();

0 commit comments

Comments
 (0)