Skip to content

feat: use mimalloc as the default allocator#16639

Draft
DaniPopes wants to merge 9 commits intoargotorg:developfrom
DaniPopes:dani/mimalloc
Draft

feat: use mimalloc as the default allocator#16639
DaniPopes wants to merge 9 commits intoargotorg:developfrom
DaniPopes:dani/mimalloc

Conversation

@DaniPopes
Copy link
Copy Markdown
Contributor

@DaniPopes DaniPopes commented Apr 24, 2026

Use mimalloc v3.3.1 as the default allocator. Linked statically with MI_OVERRIDE=ON so all malloc/free calls are replaced globally — no source changes needed. Disabled for Emscripten builds. Disable with -DUSE_MIMALLOC=OFF.

Benchmarks

Benchmark default mimalloc speedup
chains.sol 47.1 ms 40.8 ms -13%
verifier.sol 40.2 ms 35.5 ms -12%
Seaport.sol 779.4 ms 671.3 ms -14%
Solady.sol 297.5 ms 264.1 ms -11%
Solady (forge build) 12.515 s 10.966 s -12%

Fetch mimalloc v2.2.2 via FetchContent and link it statically to all
executables with MI_OVERRIDE=ON so that malloc/free are replaced
globally without any source changes. Disabled for Emscripten builds.
Can be turned off with -DUSE_MIMALLOC=OFF.
@github-actions
Copy link
Copy Markdown

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

FetchContent_MakeAvailable requires CMake 3.14+. Use the manual
FetchContent_GetProperties/FetchContent_Populate pattern instead.
Match the pattern used by fmtlib, nlohmann-json, and range-v3.
The emscripten CI image ships CMake 3.16. Instead of bumping the
project-wide minimum, guard mimalloc behind a version check and
expose MIMALLOC_ENABLED for downstream CMakeLists.
MI_OVERRIDE causes SIGABRT on macOS since Apple's allocator cannot
be fully replaced.
Static linking on macOS requires -force_load to prevent the linker
from stripping mimalloc's constructor that sets up the malloc zone
override.
mimalloc v3 requires MSVC >= VS2022 (Windows CI uses VS2019), and
macOS requires special linker flags for malloc zone constructors.
Restrict to Linux where the perf benefit matters most.
- Use CMAKE_SYSTEM_NAME=Linux instead of UNIX (excludes BSDs)
- Disable when IGNORE_VENDORED_DEPENDENCIES is set
- Disable for sanitizer builds (SANITIZE)
- Fix docs: submodule not FetchContent, document all conditions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant