Skip to content

Potential Performance Regression with dev3 #1104

@kamulos

Description

@kamulos

I just did a very quick tests with multithreaded allocation and deallocation. In this the dev3 branch does not perform very well. My CPU is 13th Gen Intel(R) Core(TM) i7-13850HX. The test code is in Rust, I hope this is ok:

# Cargo.toml

[package]
name = "experiment"
edition = "2021"

[dependencies]
rand = "0.9.1"
// main.rs

use rand::{rngs::ThreadRng, Rng};
use std::{hint::black_box, thread, time::Instant};

fn main() {
    let start = Instant::now();

    thread::scope(|scope| {
        for _ in 0..100 {
            scope.spawn(|| {
                let mut rnd = ThreadRng::default();
                for _ in 0..1000000 {
                    let allocation = vec![0u8; rnd.random_range(1..1000)];
                    black_box(&allocation);
                    if rnd.random_bool(0.24) {
                        allocation.leak();
                    }
                }
            });
        }
    });

    let duration = start.elapsed();
    println!("took {}", duration.as_secs_f32());
}

My results are (built in --release mode):

❯ LD_PRELOAD=/usr/lib/libjemalloc.so.2 ./experiment
took 0.6000622

❯ LD_PRELOAD=/home/abc/temp/mimalloc/build/libmimalloc.so.1.9 ./experiment
took 0.63197255

❯ LD_PRELOAD=/home/abc/temp/mimalloc/build/libmimalloc.so.2.2 ./experiment
took 0.62372595

❯ LD_PRELOAD=/home/abc/temp/mimalloc/build/libmimalloc.so.3.1 ./experiment
took 4.9627113

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions