std::thread
util: Replace boost sleep with std sleep #16117
pull MarcoFalke wants to merge 3 commits into bitcoin:master from MarcoFalke:1905-noBoostUtilTime changing 16 files +22 −105-
MarcoFalke commented at 12:23 pm on May 29, 2019: memberWe don’t use the interruptible feature of boost’s sleep anywhere, so replace it with the sleep in
-
MarcoFalke added the label Refactoring on May 29, 2019
-
MarcoFalke added the label Utils/log/libs on May 29, 2019
-
in src/util/time.cpp:83 in fa12affe91 outdated
87-/** 88- * Boost's sleep_for was uninterruptible when backed by nanosleep from 1.50 89- * until fixed in 1.52. Use the deprecated sleep method for the broken case. 90- * See: https://svn.boost.org/trac/boost/ticket/7238 91- */ 92-#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
laanwj commented at 12:40 pm on May 29, 2019:oh wow, can we finally get rid of this abomination? feel free to delete the detection of this as well from the build system!
MarcoFalke commented at 1:07 pm on May 29, 2019:Good idea! Done.MarcoFalke force-pushed on May 29, 2019MarcoFalke force-pushed on May 29, 2019MarcoFalke commented at 1:08 pm on May 29, 2019: memberRemoved unused configure checksfanquake requested review from theuni on May 29, 2019DrahtBot commented at 5:13 pm on May 29, 2019: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #18264 ([WIP] build: Remove Boost Chrono by fanquake)
- #18234 (refactor: Replace boost::mutex,condition_var,chrono with std equivalents in scheduler by ajtowns)
- #18149 (build: add –enable-isystem and change –enable-werror to enable -Werror by vasild)
- #18011 (Replace current benchmarking framework with nanobench by martinus)
- #15112 (build: Optionally enable -Wzero-as-null-pointer-constant by Empact)
- #14920 (Build: enable -Wdocumentation via isystem by Empact)
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.
laanwj commented at 7:27 am on May 30, 2019: memberAre the std:: versions compatible with our use of boost threadgroup interrupts?
Oh crap I knew there was a reason we hadn’t got rid of the boost::sleep madness yet :cry:
I don’t think the
std::
sleep allows any way to interrupt it, at all?I think the non-boost approach would be to have them timed-wait on a condition variable.
practicalswift commented at 1:29 pm on May 30, 2019: contributorHopefully that has no observable effects other than improved code clarity, faster compilation and faster run time.
There is a very observable effect of this PR on 32-bit systems:
Prior to this PR
bitcoind
would shut down with an assertion failure when the 32-bittime_t
overflow occurs.After this PR
bitcoind
will keep running but with negative time returned from these functions :-)practicalswift commented at 1:41 pm on May 30, 2019: contributorPerhaps we should add a test making sure
bitcoind
on 32-bit systems behave the way we want it to – which I assume is immediate shutdown? – at time of the 32-bittime_t
overflow event.Related: RFC: Improving testing under the remaining supported 32 bit platforms
laanwj commented at 3:18 pm on May 30, 2019: memberHow do other programs handle this? I though Linux switched to 64 bit timer values on 32-bit systems internally a while ago (and Linux is the only 32 bit platform supported), but I see on ARM
time_t
is still 32 bit.I mean it must be possible to handle time correctly on 32-bit systems post-2038—right?
Edit: no, apparently this is not possible?!? Threads from 2015 made my hopeful: https://lwn.net/Articles/643234/ but I don’t think this was actually addressed yet, I think.
MarcoFalke commented at 11:15 pm on May 30, 2019: memberAfter this PR bitcoind will keep running but with negative time returned from these functions :-)
Can you please explain a bit more why this happens. Be reminded that the predefined
std::chrono::duration
s use an underlying integer type that is large enough (for year 2038 to be of no problem).practicalswift commented at 7:23 am on June 6, 2019: contributorAfter this PR bitcoind will keep running but with negative time returned from these functions :-)
Can you please explain a bit more why this happens. Be reminded that the predefined
std::chrono::duration
s use an underlying integer type that is large enough (for year 2038 to be of no problem).As long as the syscall used returns 32-bit time (since epoch) on 32-bit systems this cannot be solved no matter what integer types are used to abstract time in the standard library, right? :-)
MarcoFalke closed this on Jun 10, 2019
MarcoFalke deleted the branch on Jun 10, 2019MarcoFalke commented at 7:19 am on June 10, 2019: memberYeah, and the you can’t run the underlying system anyway. There is no need to try to figure out how to make Bitcoin Core work on a broken system.practicalswift commented at 12:10 pm on June 10, 2019: contributor@MarcoFalke Perhaps we should start thinking about a deprecation plan for 32-bit systems (see #16096)? Even if this is 19 years away software tends to live longer than originally anticipated :-)MarcoFalke restored the branch on Feb 21, 2020MarcoFalke reopened this on Feb 21, 2020
util: Add UnintrruptibleSleep fa4620be78scripted-diff: Replace MilliSleep with UninterruptibleSleep
This is safe because MilliSleep is never executed in a boost::thread, the only type of thread that is interruptible. * The RPC server uses std::thread * The wallet is either executed in an RPC thread or the main thread * bitcoin-cli, benchmarks and tests are only one thread (the main thread) -BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/MilliSleep\((\S+)\);/UninterruptibleSleep(std::chrono::milliseconds{\1});/g' $(git grep -l MilliSleep) -END VERIFY SCRIPT-
util: Remove unused MilliSleep fae86c38bcMarcoFalke force-pushed on Feb 21, 2020MarcoFalke force-pushed on Feb 21, 2020MarcoFalke renamed this:
util: Replace boost:: with std:: in utiltime
util: Replace boost sleep with std sleep
on Feb 21, 2020MarcoFalke commented at 6:42 pm on February 21, 2020: memberI’ve removed the changes on the time getters, so that this doesn’t drift off into a discussion about the y2038 problemMarcoFalke added this to the "In progress" column in a project
practicalswift commented at 9:01 am on February 23, 2020: contributorACK fae86c38bca5c960462e53975314a0749db5d17d – patch looks correctsipa commented at 6:12 am on March 4, 2020: memberConcept and code review ACK fae86c38bca5c960462e53975314a0749db5d17dfanquake approvedajtowns commented at 7:15 am on March 6, 2020: memberACK fae86c38bca5c960462e53975314a0749db5d17d quick code reviewfanquake merged this on Mar 6, 2020fanquake closed this on Mar 6, 2020
MarcoFalke deleted the branch on Mar 6, 2020laanwj commented at 6:50 pm on March 6, 2020: memberPostmortem ACK.MarcoFalke moved this from the "In progress" to the "Done" column in a project
sidhujag referenced this in commit 42c06c92fd on Mar 7, 2020deadalnix referenced this in commit 4b5f81f800 on Jun 11, 2020deadalnix referenced this in commit 5a8dfec98f on Jun 11, 2020deadalnix referenced this in commit 11bc97a47f on Jun 11, 2020ftrader referenced this in commit a8748fce7c on Aug 17, 2020sidhujag referenced this in commit 7ae631b27c on Nov 10, 2020kittywhiskers referenced this in commit 9cfae9d744 on Jul 2, 2021kittywhiskers referenced this in commit 0019ec63b9 on Jul 4, 2021kittywhiskers referenced this in commit 28fb1a387b on Jul 9, 2021kittywhiskers referenced this in commit 49925e52a5 on Jul 9, 2021kittywhiskers referenced this in commit b46b64141c on Jul 9, 2021kittywhiskers referenced this in commit f0ce3afb73 on Jul 13, 2021kittywhiskers referenced this in commit 1826c3b554 on Jul 15, 2021kittywhiskers referenced this in commit b6a2e782a4 on Jul 16, 2021kittywhiskers referenced this in commit 1ad6c5e9c7 on Aug 1, 2021kittywhiskers referenced this in commit b36b489ad0 on Aug 5, 2021kittywhiskers referenced this in commit cbc4a74250 on Aug 5, 2021UdjinM6 referenced this in commit 7aebf156e9 on Aug 10, 20215tefan referenced this in commit 4204a6553f on Aug 12, 2021furszy referenced this in commit c8ad2c17ab on Aug 27, 2021DrahtBot locked this on Feb 15, 2022
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 06:12 UTC
More mirrored repositories can be found on mirror.b10c.me