Skip to content

Commit

Permalink
util(memory): use mimalloc memory allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Mar 26, 2024
1 parent c3dbe3b commit a46d6e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cmake/ExternalProjects.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ conan_cmake_configure(
"catch2/2.13.9@#8793d3e6287d3684201418de556d98fe"
"flatbuffers/23.5.26@#b153646f6546daab4c7326970b6cd89c"
"hiredis/1.0.2@#370dad964286cadb1f15dc90252e8ef3"
"mimalloc/2.1.2@#93a294cba11166006270536859c3c9ef"
"openssl/3.0.2@#269fa93e5afe8c34bd9a0030d2b8f0fe"
"protobuf/3.20.0@#8e4de7081bea093469c9e6076149b2b4"
"readerwriterqueue/1.0.6@#a95c8da3d68822dec4d4c13fff4b5c96"
Expand Down Expand Up @@ -79,6 +80,7 @@ find_package(Catch2 REQUIRED)
find_package(flatbuffers REQUIRED)
find_package(fmt REQUIRED)
find_package(hiredis REQUIRED)
find_package(mimalloc 2.1.2 REQUIRED)
# 27/01/2023 - Pin OpenSSL to a specific version to avoid incompatibilities
# with the system's (i.e. Ubuntu 22.04) OpenSSL
find_package(OpenSSL 3.0.2 REQUIRED)
Expand Down Expand Up @@ -145,6 +147,7 @@ target_link_libraries(faabric_common_dependencies INTERFACE
Boost::system
flatbuffers::flatbuffers
hiredis::hiredis
mimalloc::mimalloc
nng::nng
protobuf::libprotobuf
readerwriterqueue::readerwriterqueue
Expand Down
7 changes: 4 additions & 3 deletions include/faabric/util/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cstdint>
#include <functional>
#include <memory>
#include <mimalloc.h>
#include <span>
#include <string>
#include <unistd.h>
Expand All @@ -15,17 +16,17 @@ namespace faabric::util {
// malloc implementations.
inline void* malloc(std::size_t size)
{
return std::malloc(size);
return mi_malloc(size);
}

inline void free(void* ptr)
{
return std::free(ptr);
return mi_free(ptr);
}

inline void* realloc(void* ptr, std::size_t newSize)
{
return std::realloc(ptr, newSize);
return mi_realloc(ptr, newSize);
}

/*
Expand Down

0 comments on commit a46d6e6

Please sign in to comment.