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

refactor: use std::shared_mutex & remove Boost Thread #21064

Merged
merged 4 commits into from
Feb 12, 2021

Conversation

fanquake
Copy link
Member

@fanquake fanquake commented Feb 2, 2021

This replaces boost::shared_mutex and boost::unique_lock with std::shared_mutex & std::unique_lock.

Even though some concerns were raised in #16684 with regard to std::shared_mutex being unsafe to use across some glibc versions, I still think this change is an improvement. As I mentioned in #21022, I also think trying to restrict standard library feature usage based on bugs in glibc is not only hard to do, but it's not currently clear exactly how we do that in practice (does it also extend to patching out use in our dependencies, should we be implementing more runtime checks for features we are using, when do we consider an affected glibc "old enough" not to worry about? etc). If you take a look through the glibc bug tracker you'll no doubt find plenty of (active) bug reports for standard library code we already using. Obviously not to say we shouldn't try and avoid buggy code where possible.

Two other points:

Cory mentioned in #21022:

It also seems reasonable to me to worry that boost hits the same underlying glibc bug, and we've just not happened to trigger the right conditions yet.

Moving away from Boost to the standard library also removes the potential for differences related to Boosts configuration. Boost has multiple versions of shared_mutex, and what you end up using, and what it's backed by depends on:

  • The version of Boost.
  • The platform you're building for.
  • Which version of BOOST_THREAD_VERSION is defined: (2,3,4 or 5) default=2. (see here for some of the differences).
  • Is BOOST_THREAD_V2_SHARED_MUTEX defined? (not by default). If so, you might get the "less performant, but more robust" version of shared_mutex.

A lot of these factors are eliminated by our use of depends, but users will have varying configurations. It's also not inconceivable to think that a distro, or some package manager might start defining something like BOOST_THREAD_VERSION=3. Boost tried to change the default from 2 to 3 at one point.

With this change, we no longer use Boost Thread, so this PR also removes it from depends, the build system, CI etc.

Previous similar PRs were #19183 & #20922. The authors are included in the commits here.
Also related to #21022 - pthread sanity checking.

…ache tests

Co-authored-by: MarcoFalke falke.marco@gmail.com
Co-authored-by: sinetek pitwuu@gmail.com
Co-authored-by: MarcoFalke falke.marco@gmail.com
Co-authored-by: sinetek pitwuu@gmail.com
Adjust fuzzbuzz.yml to only install the Boost components we need.
@hebasto
Copy link
Member

hebasto commented Feb 2, 2021

Concept ACK.

@laanwj
Copy link
Member

laanwj commented Feb 2, 2021

Code review ACK 060a2a6

@practicalswift
Copy link
Contributor

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 2, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@prusnak prusnak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 060a2a6

Compiles without warnings with Clang 12, the modified cuckoocache_tests/* tests pass.

For github to pick the Co-authored-by: lines from commit messages, emails should be in <>.

@laanwj laanwj merged commit 9996b18 into bitcoin:master Feb 12, 2021
@fanquake fanquake deleted the use_std_shared_mutex branch February 12, 2021 12:28
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 12, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 13, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 15, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 15, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 17, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 24, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 11, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 11, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 15, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 15, 2021
thelazier pushed a commit to thelazier/dash that referenced this pull request Sep 19, 2021
thelazier pushed a commit to thelazier/dash that referenced this pull request Sep 25, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants