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

benchmarks: lock performance for 1, 2, 4, 8 threads wanting lock #1994

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

weissi
Copy link
Member

@weissi weissi commented Nov 27, 2021

Motivation:

To judge the cost of PTHREAD_MUTEX_ERRORCHECK as well as
os_unfair_lock vs pthread_mutex_t it's useful to have a few simple
benchmarks.

Modification:

Add lock benchmarks.

Result:

Better data.

Motivation:

To judge the cost of `PTHREAD_MUTEX_ERRORCHECK` as well as
`os_unfair_lock` vs `pthread_mutex_t` it's useful to have a few simple
benchmarks.

Modification:

Add lock benchmarks.

Result:

Better data.
@weissi weissi requested a review from Lukasa November 27, 2021 22:10
@Lukasa Lukasa added the needs-no-version-bump For PRs that when merged do not need a bump in version number. label Nov 29, 2021
@Lukasa
Copy link
Contributor

Lukasa commented Nov 29, 2021

@swift-nio-bot test this please

@Lukasa
Copy link
Contributor

Lukasa commented Nov 29, 2021

Nightly build failure is unrelated so I'm merging over the top of it.

@Lukasa Lukasa merged commit 2ef5cbe into apple:main Nov 29, 2021
Lukasa added a commit that referenced this pull request Nov 29, 2021
Motivation:

`pthread_mutex_t` locks can do advanced error checking with
`PTHREAD_MUTEX_ERRORCHECK`, the cost of which was unknown. With #1994 I
could now measure it.

The differences from my local machine (M1 MBP) for uncontended locks
are:

- on Linux: 10% faster without `PTHREAD_MUTEX_ERRORCHECK`
- on macOS: 25% faster without `PTHREAD_MUTEX_ERRORCHECK`!

Modification:

Do the extended error checking only in debug mode. Note that we still
`precondition` on all pthread return values (which is basically free).

Result:

Faster code.

Co-authored-by: Cory Benfield <lukasa@apple.com>
@weissi weissi deleted the jw-lock-perf branch November 29, 2021 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-no-version-bump For PRs that when merged do not need a bump in version number.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants