Skip to content

sync: uncontended mutex / batch_semaphore is slower compared to other implementations (eg. async-mutex) #2555

Answered by carllerche
cynecx asked this question in General
Discussion options

You must be logged in to vote

This micro benchmark is unrelated to how you would use an async mutex in practice. In this scenario, you would want to use a regular mutex. When the critical section does not span yield points, we direct users to use the parking_lot mutex directly. You should compare against that.

An async mutex only makes sense when the critical section spans yield points. In that case, you want fairness. Without fairness, under contention, you will easily end up w/ tasks that get blocked indefinitely. This results in very large latency distributions which is something you really want to avoid in production.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by hawkw
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #2555 on May 21, 2020 18:58.