Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance reduced in 6.x #306

Open
tyan-boot opened this issue Jun 28, 2024 · 4 comments
Open

performance reduced in 6.x #306

tyan-boot opened this issue Jun 28, 2024 · 4 comments

Comments

@tyan-boot
Copy link

After upgrade to version 6.0.1, it seems the latency increased, here is my benchmark result using criterion:

Maps/dash-map/read/v5   time:   [165.64 ns 171.17 ns 176.44 ns]
                        change: [-4.5163% +1.9547% +8.3860%] (p = 0.55 > 0.05)
                        No change in performance detected.
Maps/dash-map/read/v6   time:   [342.38 ns 354.98 ns 366.45 ns]
                        change: [-7.5138% +2.9050% +15.397%] (p = 0.61 > 0.05)
                        No change in performance detected.

This my code used to benchmark:

use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
use dashmap::DashMap;
use dashmap6::{DashMap as DashMap6};

type MyID = [u8; 5];

fn bench_maps(c: &mut Criterion) {
    let mut group = c.benchmark_group("Maps");
    group.bench_function("dash-map/read/v5", |b| {
        b.iter_batched(
            || {
                let maps = DashMap::new();
                maps.insert(MyID::from([1, 2, 3, 4, 5]), MyID::default());
                maps
            },
            |maps| {
                criterion::black_box(maps.get(&MyID::from([1, 2, 3, 4, 5])));
            },
            BatchSize::SmallInput,
        )
    });
    group.bench_function("dash-map/read/v6", |b| {
        b.iter_batched(
            || {
                let maps = DashMap6::new();
                maps.insert(MyID::from([1, 2, 3, 4, 5]), MyID::default());
                maps
            },
            |maps| {
                criterion::black_box(maps.get(&MyID::from([1, 2, 3, 4, 5])));
            },
            BatchSize::SmallInput,
        )
    });
}

criterion_group!(benches, bench_maps);
criterion_main!(benches);

Cargo.toml

[dependencies]
dashmap = { version = "5.5.3", features = ["inline"] }
dashmap6 = { version = "6", package = "dashmap", features = ["inline"] }


[dev-dependencies]
criterion = "0.5.1"

[[bench]]
name = "map"
path = "benches/map.rs"
harness = false

Environment

Tested on Apple M1, M2, both running macOS
Also test on AMD 5600G which runs Windows 11

Rust version output by rustc -vV

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: aarch64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7
@tyan-boot
Copy link
Author

And bench result on Windows11 AMD 5600G

Maps/dash-map/read/v5   time:   [212.48 ns 236.06 ns 262.47 ns]
                        change: [-18.107% -9.0717% +0.9671%] (p = 0.08 > 0.05)
                        No change in performance detected.
Maps/dash-map/read/v6   time:   [273.19 ns 301.81 ns 331.36 ns]
                        change: [-7.7231% +2.7725% +15.169%] (p = 0.65 > 0.05)

@cxw620
Copy link

cxw620 commented Jul 16, 2024

Update: notice commit 92d64ba78c2e0d418a7dc16abb89872f7e8f7301, PR #303 cause such regression.

Here's the test result after I revert the commit:

Maps/dash-map/read/v5   time:   [349.53 ns 361.70 ns 372.76 ns]
                        change: [-14.103% -1.2692% +12.890%] (p = 0.85 > 0.05)
                        No change in performance detected.
Maps/dash-map/read/v6   time:   [166.15 ns 189.84 ns 210.08 ns]
                        change: [-16.376% -2.6358% +12.527%] (p = 0.74 > 0.05)
                        No change in performance detected.

Notice great pref regression, too. About 2x slower, similar to tyan's result on Apple platform.

Maps/dash-map/read/v5   time:   [361.47 ns 375.36 ns 387.71 ns]
                        change: [-11.272% +1.3747% +16.931%] (p = 0.85 > 0.05)
                        No change in performance detected.
Maps/dash-map/read/v6   time:   [663.62 ns 713.58 ns 756.31 ns]
                        change: [-21.620% -4.4423% +16.276%] (p = 0.65 > 0.05)
                        No change in performance detected.

Env: Debian 12, R7-8845HS

rustc 1.81.0-nightly (24d2ac0b5 2024-07-15)
binary: rustc
commit-hash: 24d2ac0b56fcbde13d827745f66e73efb1e17156
commit-date: 2024-07-15
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Profile:

opt-level = 3
debug = false
lto = true
codegen-units = 1
split-debuginfo = "packed"
strip = "debuginfo"
panic = "unwind"

@esemeniuc
Copy link

@xacrimon any thoughts?

@cxw620
Copy link

cxw620 commented Oct 3, 2024

Well, according to the result of conc-map-bench (also created by xacrimon) , 6.0.1 actually outperforms 5.5.3, though slightly.

I believe this is the reason why xacrimon retains the commit 92d64ba78c2e0d418a7dc16abb89872f7e8f7301, as dashmap's primary goal is to replace rwlock + hashmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants