mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-07 03:48:42 +03:00
improve macOS M1 performance; use interpose in combination with zone's; add -fno-builtin-malloc flag in building with MI_OVERRIDE
This commit is contained in:
parent
751a2249c8
commit
32ee13f41e
3 changed files with 223 additions and 50 deletions
|
@ -12,7 +12,7 @@ option(MI_XMALLOC "Enable abort() call on memory allocation failure by
|
|||
option(MI_SHOW_ERRORS "Show error and warning messages by default (only enabled by default in DEBUG mode)" OFF)
|
||||
option(MI_USE_CXX "Use the C++ compiler to compile the library (instead of the C compiler)" OFF)
|
||||
option(MI_SEE_ASM "Generate assembly files" OFF)
|
||||
option(MI_OSX_INTERPOSE "Use interpose to override standard malloc on macOS" OFF)
|
||||
option(MI_OSX_INTERPOSE "Use interpose to override standard malloc on macOS" ON)
|
||||
option(MI_OSX_ZONE "Use malloc zone to override standard malloc on macOS" ON)
|
||||
option(MI_LOCAL_DYNAMIC_TLS "Use slightly slower, dlopen-compatible TLS mechanism (Unix)" OFF)
|
||||
option(MI_BUILD_SHARED "Build shared library" ON)
|
||||
|
@ -78,12 +78,17 @@ if(MI_OVERRIDE)
|
|||
message(STATUS " Use malloc zone to override malloc (MI_OSX_ZONE=ON)")
|
||||
list(APPEND mi_sources src/alloc-override-osx.c)
|
||||
list(APPEND mi_defines MI_OSX_ZONE=1)
|
||||
if (NOT MI_OSX_INTERPOSE)
|
||||
message(STATUS " WARNING: zone overriding usually also needs interpose (use -DMI_OSX_INTERPOSE=ON)")
|
||||
endif()
|
||||
endif()
|
||||
if(MI_OSX_INTERPOSE)
|
||||
# use interpose on macOS
|
||||
message(STATUS " Use interpose to override malloc (MI_OSX_INTERPOSE=ON)")
|
||||
message(STATUS " WARNING: interpose does not seem to work reliably on the M1; use -DMI_OSX_ZONE=ON instead")
|
||||
list(APPEND mi_defines MI_OSX_INTERPOSE)
|
||||
if (NOT MI_OSX_ZONE)
|
||||
message(STATUS " WARNING: interpose usually also needs zone overriding (use -DMI_OSX_INTERPOSE=ON)")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -188,6 +193,9 @@ if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU|Intel" AND NOT CMAKE_SYSTEM
|
|||
else()
|
||||
list(APPEND mi_cflags -ftls-model=initial-exec)
|
||||
endif()
|
||||
if(MI_OVERRIDE)
|
||||
list(APPEND -fno-builtin-malloc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
|
||||
|
@ -364,7 +372,7 @@ if (MI_BUILD_TESTS)
|
|||
target_compile_definitions(mimalloc-test-api PRIVATE ${mi_defines})
|
||||
target_compile_options(mimalloc-test-api PRIVATE ${mi_cflags})
|
||||
target_include_directories(mimalloc-test-api PRIVATE include)
|
||||
target_link_libraries(mimalloc-test-api PRIVATE mimalloc-static ${mi_libraries})
|
||||
target_link_libraries(mimalloc-test-api PRIVATE mimalloc ${mi_libraries})
|
||||
|
||||
add_executable(mimalloc-test-stress test/test-stress.c)
|
||||
target_compile_definitions(mimalloc-test-stress PRIVATE ${mi_defines})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue