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

CondVar is slower than std version #448

Open
chenfengyuan opened this issue Jul 16, 2024 · 0 comments
Open

CondVar is slower than std version #448

chenfengyuan opened this issue Jul 16, 2024 · 0 comments

Comments

@chenfengyuan
Copy link

chenfengyuan commented Jul 16, 2024

code use parking_lot
code use std

After cargo build -r and run, I have below results.

version duration
parking_lot 34.016281622s
std 6.342443319s

Version:
rust 1.79.0
parking_lot v0.12.3

Benchmark results:
rust 1.79.0
commit id ca920b3
cargo run --bin mutex --release -- 9:36:9 5 5 2 2

- Running with 9 threads
- 5 iterations inside lock, 5 iterations outside lock
- 2 seconds per test
        name         |    average     |     median     |    std.dev.
parking_lot::Mutex   |    688.961 kHz |    686.070 kHz |    157.593 kHz
std::sync::Mutex     |   1056.229 kHz |   1066.855 kHz |     60.092 kHz
pthread_mutex_t      |   1472.396 kHz |   1442.833 kHz |    138.366 kHz
- Running with 18 threads
        name         |    average     |     median     |    std.dev.
parking_lot::Mutex   |     48.460 kHz |     48.602 kHz |      4.002 kHz
std::sync::Mutex     |    521.675 kHz |    530.139 kHz |     28.304 kHz
pthread_mutex_t      |    734.650 kHz |    731.346 kHz |     38.607 kHz
- Running with 27 threads
        name         |    average     |     median     |    std.dev.
parking_lot::Mutex   |     24.781 kHz |     24.858 kHz |      0.475 kHz
std::sync::Mutex     |    340.293 kHz |    341.380 kHz |     21.122 kHz
pthread_mutex_t      |    485.667 kHz |    484.665 kHz |     25.619 kHz
- Running with 36 threads
        name         |    average     |     median     |    std.dev.
parking_lot::Mutex   |     18.455 kHz |     19.806 kHz |      1.716 kHz
std::sync::Mutex     |    255.091 kHz |    256.855 kHz |     16.656 kHz
pthread_mutex_t      |    362.141 kHz |    360.492 kHz |     23.749 kHz
@chenfengyuan chenfengyuan changed the title CondVar slower than std version CondVar is slower than std version Jul 17, 2024
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

1 participant