13 releases

✓ Uses Rust 2018 edition

0.2.9 Apr 1, 2020
0.2.8 Mar 21, 2020
0.2.4 Feb 13, 2020
0.2.1 Jan 24, 2020
0.1.2 Jan 21, 2020

#78 in Memory management

Download history 14/week @ 2020-01-14 67/week @ 2020-01-21 34/week @ 2020-01-28 76/week @ 2020-02-04 93/week @ 2020-02-11 96/week @ 2020-02-18 134/week @ 2020-02-25 843/week @ 2020-03-03 600/week @ 2020-03-10 424/week @ 2020-03-17 637/week @ 2020-03-24 1060/week @ 2020-03-31

1,029 downloads per month
Used in 2 crates (via snmalloc-rs)

MIT license

1.5MB
1.5K SLoC

C++ 1.5K SLoC // 0.0% comments Rust 87 SLoC // 0.2% comments Shell 26 SLoC // 0.1% comments

snmalloc-rs

MSVC/MinGW/Linux/MacOS: travis ci

FreeBSD: Build Status

snmalloc-rs provides a wrapper for microsoft/snmalloc to make it usable as a global allocator for rust. snmalloc is a research allocator. 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.
  • The allocator uses large ranges of pages to reduce the amount of meta-data required.

Some old benchmark results are available in the snmalloc paper. There are three features defined in this crate:

  • debug: Enable the Debug mode in snmalloc.
  • 1mib: Use the 1mib chunk configuration.
  • cache-friendly: Make the allocator more cache friendly (setting CACHE_FRIENDLY_OFFSET to 64 in building the library).

To use snmalloc-rs add it as a dependency:

# Cargo.toml
[dependencies]
snmalloc-rs = "0.2"

To set SnMalloc as the global allocator add this to your project:

#[global_allocator]
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;

For MinGW Users

mingw version is only tested on nighly branch. Due to the complexity of locating GNU libraries on Windows environment, the library requests you to provide a MINGW64_BIN environment variable during compiling. Since GCC does not provide a option for us to link libatomic statically, I have to use dynamic linking. Hence, please make sure the following libs are in your PATH:

  • winpthread
  • atomic
  • stdc++
  • gcc_s

This is the best thing I can do for current stage, if you have any better solution, please do help me to provide a better support for MinGW

Changelog

0.2.9 - upstream fix OpenEnclave

  • upstream adjust remote batch size (performance improved dramatically, see benchmark
  • upstream improve slow path performance for allocation

0.2.8

  • More CI (ARM64 on QEMU)
  • upstream ARM(32/64) support
  • upstream x86-SGX support

0.2.7

  • partially fixed mingw
  • upstream remote dealloc refactor (higher performance)
  • upstream remove extra assertions

for older versions, see CHANGELOG

Dependencies