• Stars
    star
    118
  • Rank 299,923 (Top 6 %)
  • Language
    Rust
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

rust bindings of snmalloc

snmalloc-rs

Notice: MinGW Build is broken and may not be fixed in a near future. See this PR in the upstream.

MSVC/MinGW/Linux/MacOS: Actions Status

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. Some recent benchmark results are listed at bench_suite. There are three features defined in this crate:

  • debug: Enable the Debug mode in snmalloc.
  • 1mib: Use the 1mib chunk configuration. From 0.2.17, this is set as a default feature (removed since 0.3.0)
  • 16mib: Use the 16mib chunk configuration. (removed since 0.3.0)
  • cache-friendly: Make the allocator more cache friendly (setting CACHE_FRIENDLY_OFFSET to 64 in building the library). (removed since 0.3.0)
  • native-cpu: Optimize snmalloc for the native CPU of the host machine. (this is not a default behavior since 0.2.14)
  • qemu: Workaround madvise problem of QEMU environment
  • stats: Enable statistics (removed since 0.3.0)
  • local_dynamic_tls: Workaround cannot allocate memory in static tls block
  • build_cc: Use of cc crate instead of cmake (cmake still default) as builder (more platform agnostic)
  • usecxx20: Enable C++20 standard if available (removed since 0.3.0)
  • usecxx17: Use C++17 standard
  • check: Enable extra checks to improve security, see upstream security docs. Note that the memcpy protection is not enabled in Rust.
  • win8compat: Improve compatibility for old Windows platforms (removing usages of VirtualAlloc2 and other new APIs)

To get the crates compiled, you need to choose either 1mib or 16mib to determine the chunk configuration

To use snmalloc-rs add it as a dependency:

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

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 nightly branch with MSYS environment. We are using dynamic linking method. Hence, please make sure the following libs are in your PATH:

  • winpthread
  • atomic
  • stdc++
  • gcc_s

Notice: since version 0.2.12, we no longer require you to provide additional environment variables for mingw target.

For Android Cross-Compilation

  • ANDROID_NDK must be provided as an environment variable
  • ANDROID_PLATFORM can be passed as an optional environment variable
  • ANDROID_ABI used by CMake is detected automatically
  • feature android-lld can be used to set the linker of snmalloc to lld
  • feature android-shared-std can be used to set the STL library of snmalloc to c++_shared (it uses c++_static by default) (libstdc++ is no longer a dependency)

Changelog

0.3.4

  • Tracking upstream to version 0.6.2.

0.3.3

  • Tracking upstream to fix Linux PAL typo.

0.3.2

  • Tracking upstream to enable old Linux variants.

0.3.1

  • Fixes build_cc feature (broken in 0.3.0 release).
  • Fixes native-cpu feature (broken in 0.3.0 release).

0.3.0

  • Release to support snmalloc 0.6.0.

0.3.0-beta.1

  • Beta release to support snmalloc 2 0.6.0

More Repositories

1

paguroidea

A reimplementation of the Flap parser in Rust (with our own modifications applied)!
Rust
53
star
2

VNMCC

Very Naive MIPS CPU using Clash
TeX
29
star
3

tabbycat

dotgraph generator for rust
Rust
18
star
4

bench_suite

Python
17
star
5

ReuseIR

Reuse Analysis in MLIR and Rust. Functional programming meets performance.
C++
15
star
6

memcpy-amd64

An implementation of memcpy for amd64 with clang/gcc
C++
14
star
7

rura

RUst way for Reuse Analysis
Rust
13
star
8

crc64-cxx

SIMD CRC64 for C++
C++
11
star
9

LeanGccBackend

Lean4 backend using `libgccjit`!
Lean
10
star
10

StanfordLib-CUHKSZ

A cmake delivery version of stanford library, specially patched for CSC3002 students in CUHK(SZ)
C++
10
star
11

ahash-cxx

A variant of Ahash written in C++.
C++
9
star
12

koka-collections

Purely functional data structures in Koka
Python
9
star
13

assembler

Data Parallel MIPS Toy Assembler
C++
8
star
14

lean-gccjit

libgccjit bindings for Lean4
Lean
7
star
15

bfprt

c++ implementation of bfprt algorithm
C++
7
star
16

pika_cxx

A WIP C++ Implementation of Packrat & PIKA Parser (for study purpose)
C++
6
star
17

wfarc

Wait-Free Weak Reference Counting in Rust
Rust
6
star
18

in-memory-btree

just an in-memory-btree
C++
6
star
19

ahash-c

A pure C re-implementation of rust aHash, with aarch64 support
C
6
star
20

stanford-cpp-library-cmake

stanford-cpp-library empty project, using cmake as build toolchain
C++
6
star
21

unwinder

Rust
5
star
22

libmprompt-sys

raw bindings to libmprompt for rust
Rust
5
star
23

simulator

a toy simulator for MIPS
C++
4
star
24

simplebf

brainf**k native compiler (for fun)
C++
4
star
25

dynforest

A rust crate for dynamic forest management
Rust
4
star
26

SwissTableJavaVectorAPI

A proof-of-concept implementation of swisstable in Java using Vector API
Java
4
star
27

micro-jit

A micro language JIT written on Truffle
Java
4
star
28

data_structure_for_love

data structure project
C++
3
star
29

swisstable_kk

Mutable Swisstable for Koka.
C
3
star
30

libc-free

Rust
3
star
31

backend

A work in progress compiler backend for MIPS
C++
3
star
32

domtree

A generic rust crate for dominance relation calculation.
Rust
3
star
33

flist

Elixir list implement with the data structure of fingertree
Elixir
3
star
34

micro_compiler

C++
3
star
35

clearup

A very simple LKM for cache and TLB clearing
C
3
star
36

nbe-at-large

learning of NbE
Rust
3
star
37

egraph-step-by-step

step by step learning of egraphs
Rust
3
star
38

hashbrown4lean

Rust
3
star
39

MorningStar-IR

Middle Level Special Intermediate Representation (Research Design of IR with Equality Saturation Ability for Pr47)
2
star
40

area-exam-survey

Reuse Analysis, Review and Rethinking
Typst
2
star
41

lean-hovercraft

floating point writers and readers
C++
2
star
42

veb

An functional implement of the RS-vEB tree.
Elixir
2
star
43

SinkSCC

A C++ implementation of the graph algorithm of finding all strongly connected components with DFS
C++
2
star
44

toylibc

Rust
2
star
45

Minimal-Surface-and-Obstacles

DDA/CIE-project
MATLAB
2
star
46

lambda-lock

Rust
2
star
47

libcrc64

Fast CRC64 implementation from rust
Rust
1
star
48

graphics-final

CMake
1
star
49

keeper-core2

Rust
1
star
50

LGU-LUG

1
star
51

loom4c

locksmith's playground
Rust
1
star
52

dch_joking

ε–΅ε–΅ε–΅~
Elixir
1
star
53

exqueue

Several simple implements of functional queue data structures in Elixir.
Elixir
1
star
54

tiflash-env

Development environment for TiFlash
Shell
1
star
55

vEB_tree

The giant data structure of van Emde Boas tree.
C++
1
star
56

reuse-ir

C++
1
star
57

pag-final-evaluation-cc24

More evaluations for "Paguroidea: Fused Parser Generator with Transparent Semantic Actions" (To be presented at CC'24)
OCaml
1
star
58

reuse-runtime

A reuse runtime designed for cyrup language (without thinking too much yet)
1
star
59

pc2mesh

C++
1
star
60

libcrc64-c

pure C implementation of CRC64 with SIMD acceleration
1
star
61

SCC

C++
1
star
62

password

my own password keeper
Rust
1
star
63

docker-spark

Shell
1
star
64

frontend

Compiler Frontend
C++
1
star
65

Paper-Reading

Tracks my paper reading status
1
star
66

Bidi-Parser

(Thesis) Bidirectional Parsing
C++
1
star