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

disable PTHREAD_MUTEX_ERRORCHECK in release mode #1995

Merged
merged 2 commits into from
Nov 29, 2021

Conversation

weissi
Copy link
Member

@weissi weissi commented Nov 27, 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.

Motivation:

`pthread_mutex_t` locks can do advanced error checking with
`PTHREAD_MUTEX_ERRORCHECK`, the cost of which was unknown. With apple#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.
@weissi weissi requested a review from Lukasa November 27, 2021 22:28
@Lukasa Lukasa added the patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Nov 29, 2021
@Lukasa
Copy link
Contributor

Lukasa commented Nov 29, 2021

@swift-nio-bot test this please

@Lukasa Lukasa merged commit d08e8ff into apple:main Nov 29, 2021
@weissi weissi deleted the jw-unchecked-pthread-lock 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
patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants