Skip to content

Commit a46d6e6

Browse files
committed
util(memory): use mimalloc memory allocator
1 parent c3dbe3b commit a46d6e6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

cmake/ExternalProjects.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ conan_cmake_configure(
3737
"catch2/2.13.9@#8793d3e6287d3684201418de556d98fe"
3838
"flatbuffers/23.5.26@#b153646f6546daab4c7326970b6cd89c"
3939
"hiredis/1.0.2@#370dad964286cadb1f15dc90252e8ef3"
40+
"mimalloc/2.1.2@#93a294cba11166006270536859c3c9ef"
4041
"openssl/3.0.2@#269fa93e5afe8c34bd9a0030d2b8f0fe"
4142
"protobuf/3.20.0@#8e4de7081bea093469c9e6076149b2b4"
4243
"readerwriterqueue/1.0.6@#a95c8da3d68822dec4d4c13fff4b5c96"
@@ -79,6 +80,7 @@ find_package(Catch2 REQUIRED)
7980
find_package(flatbuffers REQUIRED)
8081
find_package(fmt REQUIRED)
8182
find_package(hiredis REQUIRED)
83+
find_package(mimalloc 2.1.2 REQUIRED)
8284
# 27/01/2023 - Pin OpenSSL to a specific version to avoid incompatibilities
8385
# with the system's (i.e. Ubuntu 22.04) OpenSSL
8486
find_package(OpenSSL 3.0.2 REQUIRED)
@@ -145,6 +147,7 @@ target_link_libraries(faabric_common_dependencies INTERFACE
145147
Boost::system
146148
flatbuffers::flatbuffers
147149
hiredis::hiredis
150+
mimalloc::mimalloc
148151
nng::nng
149152
protobuf::libprotobuf
150153
readerwriterqueue::readerwriterqueue

include/faabric/util/memory.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <cstdint>
44
#include <functional>
55
#include <memory>
6+
#include <mimalloc.h>
67
#include <span>
78
#include <string>
89
#include <unistd.h>
@@ -15,17 +16,17 @@ namespace faabric::util {
1516
// malloc implementations.
1617
inline void* malloc(std::size_t size)
1718
{
18-
return std::malloc(size);
19+
return mi_malloc(size);
1920
}
2021

2122
inline void free(void* ptr)
2223
{
23-
return std::free(ptr);
24+
return mi_free(ptr);
2425
}
2526

2627
inline void* realloc(void* ptr, std::size_t newSize)
2728
{
28-
return std::realloc(ptr, newSize);
29+
return mi_realloc(ptr, newSize);
2930
}
3031

3132
/*

0 commit comments

Comments
 (0)