File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ conan_cmake_configure(
39
39
"cpprestsdk/2.10.18@#ed9788e9d202d6eadd92581368ddfc2f"
40
40
"flatbuffers/2.0.5@#c6a9508bd476da080f7aecbe7a094b68"
41
41
"hiredis/1.0.2@#370dad964286cadb1f15dc90252e8ef3"
42
+ "mimalloc/2.1.2@#93a294cba11166006270536859c3c9ef"
42
43
"openssl/3.0.2@#269fa93e5afe8c34bd9a0030d2b8f0fe"
43
44
"protobuf/3.20.0@#8e4de7081bea093469c9e6076149b2b4"
44
45
"readerwriterqueue/1.0.6@#a95c8da3d68822dec4d4c13fff4b5c96"
@@ -88,6 +89,7 @@ find_package(cpprestsdk REQUIRED)
88
89
find_package (FlatBuffers REQUIRED)
89
90
find_package (fmt REQUIRED)
90
91
find_package (hiredis REQUIRED)
92
+ find_package (mimalloc 2.1.2 REQUIRED)
91
93
# 27/01/2023 - Pin OpenSSL to a specific version to avoid incompatibilities
92
94
# with the system's (i.e. Ubuntu 22.04) OpenSSL
93
95
find_package (OpenSSL 3.0.2 REQUIRED)
@@ -155,6 +157,7 @@ target_link_libraries(faabric_common_dependencies INTERFACE
155
157
cpprestsdk::cpprestsdk
156
158
flatbuffers::flatbuffers
157
159
hiredis::hiredis
160
+ mimalloc::mimalloc
158
161
nng::nng
159
162
protobuf::libprotobuf
160
163
readerwriterqueue::readerwriterqueue
Original file line number Diff line number Diff line change 3
3
#include < cstdint>
4
4
#include < functional>
5
5
#include < memory>
6
+ #include < mimalloc.h>
6
7
#include < span>
7
8
#include < string>
8
9
#include < unistd.h>
@@ -15,12 +16,17 @@ namespace faabric::util {
15
16
// malloc implementations.
16
17
inline void * malloc (std::size_t size)
17
18
{
18
- return std::malloc (size);
19
+ return mi_malloc (size);
19
20
}
20
21
21
22
inline void free (void * ptr)
22
23
{
23
- return std::free (ptr);
24
+ return mi_free (ptr);
25
+ }
26
+
27
+ inline void * realloc (void * ptr, std::size_t newSize)
28
+ {
29
+ return mi_realloc (ptr, newSize);
24
30
}
25
31
26
32
/*
Original file line number Diff line number Diff line change @@ -14,6 +14,19 @@ using namespace faabric::util;
14
14
15
15
namespace tests {
16
16
17
+ TEST_CASE (" Test faabric-namespaced memory allocators" )
18
+ {
19
+ // Smoke test to make sure the symbols are defined and work as expected
20
+ size_t mallocSize = 0x100 * sizeof (int );
21
+ void * ptr = faabric::util::malloc (mallocSize);
22
+ REQUIRE (ptr != nullptr );
23
+
24
+ void * newPtr = faabric::util::realloc (ptr, mallocSize * 2 );
25
+ REQUIRE (newPtr != nullptr );
26
+
27
+ REQUIRE_NOTHROW (faabric::util::free (newPtr));
28
+ }
29
+
17
30
TEST_CASE (" Test rounding down offsets to page size" , " [util][memory]" )
18
31
{
19
32
REQUIRE (faabric::util::alignOffsetDown (2 * faabric::util::HOST_PAGE_SIZE) ==
You can’t perform that action at this time.
0 commit comments