3 ms·
TLDR for people who didn't read: The speed difference came from the allocator. Rust switched from jemalloc to the system allocator per ticket #36963[0] for va
by pcr910303 7y ago
TLDR for people who didn't read:
The speed difference came from the allocator.
Rust switched from jemalloc to the system allocator per ticket #36963[0] for various reasons (like binary bloat, valgrind incompatibility, etc...).
Go uses a custom allocator[1] instead.
To make 'Rust Go fast' (pun intended), one can use the '#[global_allocator]' to use a custom allocator (in this case, with the jemallocator crate) to make allocations fast again.
[0]: https://github.com/rust-lang/rust/issues/36963 https://github.com/rust-lang/rust/issues/36963
[1]: https://golang.org/src/runtime/malloc.go https://golang.org/src/runtime/malloc.go