10837 shaares
386 private links
386 private links
The heap is a performance killer in Rust. One woraround is to swap to a more efficient memory allocator such as jemalloc.
In Cargo.toml:
[dependencies]
mimalloc = "0.1"
In main.rs:
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
The best performance optimisation is to avoid the heap. There is the heapless
create for that. "The only thing to know is that the size of heapless types and collections needs to be known at compile-time."