Conversation
|
utACK 2a4338c5054906b664e027b1b4bb9c6b4ed50f05 |
|
utACK 2a4338c |
|
Force-pushed a new head commit: I just noticed that The |
|
@kazcw I prefer seeing correct synchronization, even for variables that are only accessed from one thread. There are probably several such violations already, but over time, I think we'll want multiple message handler threads. |
|
Can one of the admins verify this patch? |
|
@kazcw Can you add some form of synchronization back to CNode::minFeeFilter? |
|
Sure, I popped off the |
|
Is there any advantage to making this boolean thread-local instead of atomic? |
|
@laanwj I assume a thread-local is slightly faster as it doesn't need memory synchronization (but that's a pure guess). |
|
On the other hand, an atomic would be nice to guarantee monotonicity... |
|
@laanwj I'd thought it was a little simpler to avoid the need for cross-thread reasoning, but I'm not so sure; an atomic seems to map more directly to the intent here. I'd also made a similar performance assumption to @sipa, but looking in to it now there are apparently some thorny thread-local storage implementations in the wild. So, I've reimplemented it with an atomic for clarity and consistent performance. |
|
utACK b07b3f9c1a4b1a0b5f7189f9a0e45cf7547582cf |
src/main.cpp
Outdated
|
utACK a91c897 |
Optimistically test the latch bool before taking the lock. For all IsInitialBlockDownload calls after the first to return false, this avoids the need to lock cs_main.
|
Squashed & fixed comment |
|
utACK b07b3f9
Right. On hardware that natively supports atomic operations (which are most modern CPUs), I'd expect an atomic to be slightly more performant. Thread-local variables, classically at least, come with serious overhead, like having to set up a special segment. That's worth it for larger per-thread data structures, but not one boolean. |
f0fdda0 IsInitialBlockDownload: usually avoid locking (Kaz Wesley)
f0fdda0 IsInitialBlockDownload: usually avoid locking (Kaz Wesley)
InitialBlockDownload upstream changes Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7208 - bitcoin/bitcoin#8007 - bitcoin/bitcoin#9053 - Excluding second commit (requires bitcoin/bitcoin#8865) - bitcoin/bitcoin#10388
InitialBlockDownload upstream changes Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7208 - bitcoin/bitcoin#8007 - bitcoin/bitcoin#9053 - Excluding second commit (requires bitcoin/bitcoin#8865) - bitcoin/bitcoin#10388
InitialBlockDownload upstream changes Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7208 - bitcoin/bitcoin#8007 - bitcoin/bitcoin#9053 - Excluding second commit (requires bitcoin/bitcoin#8865) - bitcoin/bitcoin#10388
f0fdda0 IsInitialBlockDownload: usually avoid locking (Kaz Wesley)
9e378e4 IsInitialBlockDownload: usually avoid locking (furszy) Pull request description: Straightforward, coming from [btc@8007](bitcoin#8007) ACKs for top commit: random-zebra: Nice! utACK 9e378e4 Fuzzbawls: utACK 9e378e4 Tree-SHA512: 3f5ebfbafa64ca7ff5397405c87f0030d81a4342486e420c7f3bf03daef08947afb22aed9d20bff02b4376a64e02902b9882c637e7a94ec235c4a5d4e1280391
A tweak to
IsInitialBlockDownloadprevents takingcs_mainmost of the time: it already remembers a negative result to save some work; doing so per-thread allows the check to be pulled out of the lock.cs_feeFilteris used only to guardminFeeFilter, which is an integer. This is the simplest use case of anatomicvariable: the only guarantee needed is atomicity.