mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-18 19:40:40 +01:00
Merge bitcoin/bitcoin#27189: util: Use steady clock in SeedStrengthen, FindBestImplementation, FlushStateToDisk
fa1b4e5c32Use steady clock in FlushStateToDisk (MarcoFalke)1111e2f8b4Use 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: ACKfa1b4e5c32willcl-ark: ACKfa1b4e5c3Tree-SHA512: cc625e796b186accd53222bd64eb57d0512bc7e588312d254349b542bbc5e5daac348ff2b3b3f7dc5ae0bbbae2ec11fdbf3022cf2164211633765a4b0108e83e
This commit is contained in:
@@ -2478,12 +2478,12 @@ bool Chainstate::FlushStateToDisk(
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto nNow = GetTime<std::chrono::microseconds>();
|
||||
const auto nNow{SteadyClock::now()};
|
||||
// Avoid writing/flushing immediately after startup.
|
||||
if (m_last_write.count() == 0) {
|
||||
if (m_last_write == decltype(m_last_write){}) {
|
||||
m_last_write = nNow;
|
||||
}
|
||||
if (m_last_flush.count() == 0) {
|
||||
if (m_last_flush == decltype(m_last_flush){}) {
|
||||
m_last_flush = nNow;
|
||||
}
|
||||
// The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing).
|
||||
@@ -2544,7 +2544,7 @@ bool Chainstate::FlushStateToDisk(
|
||||
m_last_flush = nNow;
|
||||
full_flush_completed = true;
|
||||
TRACE5(utxocache, flush,
|
||||
(int64_t)(GetTimeMicros() - nNow.count()), // in microseconds (µs)
|
||||
int64_t{Ticks<std::chrono::microseconds>(SteadyClock::now() - nNow)},
|
||||
(uint32_t)mode,
|
||||
(uint64_t)coins_count,
|
||||
(uint64_t)coins_mem_usage,
|
||||
|
||||
Reference in New Issue
Block a user