aboutsummaryrefslogtreecommitdiff
path: root/src/node/minisketchwrapper.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-03-08 08:40:21 +0100
committerfanquake <fanquake@gmail.com>2023-03-08 08:48:41 +0100
commit2de0559f2cb3e02881c0b1a132481fce51a18448 (patch)
treecc8e2cf1f7deb796a30a153ce7847660fee71ebe /src/node/minisketchwrapper.cpp
parentd5e4f9a43952f294e165381116773d2aab00100d (diff)
parentfa1b4e5c3294fc9aec033892a4a4d7b5cfc015aa (diff)
Merge bitcoin/bitcoin#27189: util: Use steady clock in SeedStrengthen, FindBestImplementation, FlushStateToDisk
fa1b4e5c3294fc9aec033892a4a4d7b5cfc015aa Use steady clock in FlushStateToDisk (MarcoFalke) 1111e2f8b43cd9ed62dcf6b571a224b84fc421fd Use steady clock in SeedStrengthen and FindBestImplementation (MarcoFalke) Pull request description: There may be a theoretical deadlock for the duration of the offset when the system clock is adjusted into a past time while executing `SeedStrengthen`. Fix this by using steady clock. Do the same in `FindBestImplementation`, which shouldn't be affected, because it discards outlier measurements. However, doing the same there for consistency seems fine. Do the same in `FlushStateToDisk`, which should make the flushes more steady, if the system clock is adjusted by a large offset. ACKs for top commit: john-moffett: ACK fa1b4e5c3294fc9aec033892a4a4d7b5cfc015aa willcl-ark: ACK fa1b4e5c3 Tree-SHA512: cc625e796b186accd53222bd64eb57d0512bc7e588312d254349b542bbc5e5daac348ff2b3b3f7dc5ae0bbbae2ec11fdbf3022cf2164211633765a4b0108e83e
Diffstat (limited to 'src/node/minisketchwrapper.cpp')
-rw-r--r--src/node/minisketchwrapper.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/node/minisketchwrapper.cpp b/src/node/minisketchwrapper.cpp
index 67e823cb68..96707f7a0a 100644
--- a/src/node/minisketchwrapper.cpp
+++ b/src/node/minisketchwrapper.cpp
@@ -23,17 +23,17 @@ static constexpr uint32_t BITS = 32;
uint32_t FindBestImplementation()
{
- std::optional<std::pair<int64_t, uint32_t>> best;
+ std::optional<std::pair<SteadyClock::duration, uint32_t>> best;
uint32_t max_impl = Minisketch::MaxImplementation();
for (uint32_t impl = 0; impl <= max_impl; ++impl) {
- std::vector<int64_t> benches;
+ std::vector<SteadyClock::duration> benches;
uint64_t offset = 0;
/* Run a little benchmark with capacity 32, adding 184 entries, and decoding 11 of them once. */
for (int b = 0; b < 11; ++b) {
if (!Minisketch::ImplementationSupported(BITS, impl)) break;
Minisketch sketch(BITS, impl, 32);
- auto start = GetTimeMicros();
+ auto start = SteadyClock::now();
for (uint64_t e = 0; e < 100; ++e) {
sketch.Add(e*1337 + b*13337 + offset);
}
@@ -41,7 +41,7 @@ uint32_t FindBestImplementation()
sketch.Add(e*1337 + b*13337 + offset);
}
offset += (*sketch.Decode(32))[0];
- auto stop = GetTimeMicros();
+ auto stop = SteadyClock::now();
benches.push_back(stop - start);
}
/* Remember which implementation has the best median benchmark time. */