Skip to content

Commit b06275b

Browse files
committed
Use mimalloc allocator for static build
Which fixes performance problems, especially on heavily multi-threaded workloads (many functions, high core count machines), see #5561.
1 parent 0472ba2 commit b06275b

4 files changed

Lines changed: 11 additions & 0 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "third_party/fuzztest"]
88
path = third_party/fuzztest
99
url = https://github.com/google/fuzztest
10+
[submodule "third_party/mimalloc"]
11+
path = third_party/mimalloc
12+
url = https://github.com/microsoft/mimalloc.git

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ if(BUILD_STATIC_LIB)
446446
message(STATUS "Building libbinaryen as statically linked library.")
447447
add_library(binaryen STATIC)
448448
add_definitions(-DBUILD_STATIC_LIBRARY)
449+
450+
message(STATUS "Using mimalloc for static build to avoid bad musl libc allocator performance.")
451+
target_link_libraries(binaryen mimalloc-static)
449452
else()
450453
message(STATUS "Building libbinaryen as shared library.")
451454
add_library(binaryen SHARED)

third_party/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ endif()
1515
if(BUILD_LLVM_DWARF)
1616
add_subdirectory(llvm-project)
1717
endif()
18+
19+
if(BUILD_STATIC_LIB)
20+
add_subdirectory(mimalloc)
21+
endif()

third_party/mimalloc

Submodule mimalloc added at f11732a

0 commit comments

Comments
 (0)