Message passing based allocator
Перейти к файлу
David Chisnall b5623305b7 [NFC] clang-tidy. 2022-03-16 16:15:59 +00:00
.github/workflows try enabling windows-2022 (#445) 2022-01-07 11:24:56 +00:00
ci CI: Add RISC-V 64 cross-build & qemu-user tests 2021-10-20 12:02:08 +01:00
docs CHERI: update StrictProvenance.md for new world order 2021-12-16 19:25:09 +00:00
src [NFC] clang-tidy. 2022-03-16 16:15:59 +00:00
.clang-format Update to use clangformat9 2020-02-06 09:09:32 +00:00
.clang-tidy Add the const parameter checker. 2019-04-30 09:46:10 +01:00
.gitignore Nits for rust release (#419) 2021-11-17 16:02:47 +00:00
CMakeLists.txt shared lib linkage build fix for OpenBSD. 2022-02-28 09:16:16 +00:00
LICENSE Initial commit 2019-01-09 06:05:57 -08:00
README.md Fix status badge and LLVM fetching for qemu builds (#362) 2021-08-04 15:07:33 +01:00
difference.md Improve slow path performance for allocation (#143) 2020-03-31 09:17:53 +01:00
security.md Update documentation 2020-02-28 09:03:41 +00:00
snmalloc.pdf Add paper. 2019-05-23 15:13:47 +01:00

README.md

snmalloc

snmalloc is a high-performance allocator. snmalloc can be used directly in a project as a header-only C++ library, it can be LD_PRELOADed on Elf platforms (e.g. Linux, BSD), and there is a crate to use it from Rust.

Its key design features are:

  • Memory that is freed by the same thread that allocated it does not require any synchronising operations.
  • Freeing memory in a different thread to initially allocated it, does not take any locks and instead uses a novel message passing scheme to return the memory to the original allocator, where it is recycled. This enables 1000s of remote deallocations to be performed with only a single atomic operation enabling great scaling with core count.
  • The allocator uses large ranges of pages to reduce the amount of meta-data required.
  • The fast paths are highly optimised with just two branches on the fast path for malloc (On Linux compiled with Clang).
  • The platform dependencies are abstracted away to enable porting to other platforms.

snmalloc's design is particular well suited to the following two difficult scenarios that can be problematic for other allocators:

  • Allocations on one thread are freed by a different thread
  • Deallocations occur in large batches

Both of these can cause massive reductions in performance of other allocators, but do not for snmalloc.

Comprehensive details about snmalloc's design can be found in the accompanying paper, and differences between the paper and the current implementation are described here. Since writing the paper, the performance of snmalloc has improved considerably.

snmalloc CI

Further documentation

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.