Skip to content

Optional pure-Rust global allocator for the node #4082

Description

@freedomlovesfrank

The value of integrating

rusk pins rocksdb = { version = "0.22", default-features = false }, rayon = "1.10.0" and axum = "0.8.8", and the node binary sets no #[global_allocator] — the only one in the tree is dlmalloc for the wasm wallet core, under #[cfg(target_family = "wasm")]. So the node itself runs on whatever the host provides: glibc on most deployments, musl on the container images.

A full node is where that compounds. It validates blocks and runs zero-knowledge circuit verification continuously, writes the resulting state through rocksdb and serves HTTP alongside it, for as long as the node is in the network — and with rayon spreading verification across a pool, the thread that frees a proof buffer is usually not the thread that allocated it. The allocator's cross-thread free path sits under every block, on whichever allocator the machine happened to supply.

rusty_alloc is one allocator across every target you deploy to, with 8,851 downloads on crates.io, in safe Rust with no build script. On that cross-thread path the rusty_alloc README measures 0.83x mimalloc's instructions (xthread — every free performed by a non-owning thread).

Not asking you to change any default — this would sit behind an off-by-default feature.

How to integrate

[features]
rusty-alloc = ["dep:rusty_alloc-api"]   # opt in; nothing changes by default

[dependencies]
rusty_alloc-api = { version = "2.1", optional = true }

Then in the node binary:

#[cfg(feature = "rusty-alloc")]
#[global_allocator]
static ALLOC: rusty_alloc_api::RustyAlloc = rusty_alloc_api::RustyAlloc;

Nothing else changes: same consensus, same contracts, same wallet. The wasm wallet core keeps dlmalloc — this is only the native node binary.

Remade With Rust & MATA

We are rebuilding the C libraries Rust projects still depend on, in safe Rust — allocators, codecs, compression, parsers, identity and storage — so a build can drop its C pieces without losing performance. The org is at https://github.com/Remade-With-Rust if anything else fits. If this is not for you, please close the issue.

  • x.com/farmer_timmm

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions