mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Use steady clock for all millis bench logging
This commit is contained in:
parent
ab3db34836
commit
fa521c9603
8 changed files with 18 additions and 20 deletions
|
@ -187,11 +187,11 @@ std::optional<bilingual_str> LoadAddrman(const NetGroupManager& netgroupman, con
|
|||
auto check_addrman = std::clamp<int32_t>(args.GetIntArg("-checkaddrman", DEFAULT_ADDRMAN_CONSISTENCY_CHECKS), 0, 1000000);
|
||||
addrman = std::make_unique<AddrMan>(netgroupman, /*deterministic=*/false, /*consistency_check_ratio=*/check_addrman);
|
||||
|
||||
int64_t nStart = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
const auto path_addr{args.GetDataDirNet() / "peers.dat"};
|
||||
try {
|
||||
DeserializeFileDB(path_addr, *addrman, CLIENT_VERSION);
|
||||
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->size(), GetTimeMillis() - nStart);
|
||||
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->size(), Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
} catch (const DbNotFoundError&) {
|
||||
// Addrman can be in an inconsistent state after failure, reset it
|
||||
addrman = std::make_unique<AddrMan>(netgroupman, /*deterministic=*/false, /*consistency_check_ratio=*/check_addrman);
|
||||
|
|
|
@ -31,12 +31,12 @@ void BanMan::LoadBanlist()
|
|||
|
||||
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…").translated);
|
||||
|
||||
int64_t n_start = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
if (m_ban_db.Read(m_banned)) {
|
||||
SweepBanned(); // sweep out unused entries
|
||||
|
||||
LogPrint(BCLog::NET, "Loaded %d banned node addresses/subnets %dms\n", m_banned.size(),
|
||||
GetTimeMillis() - n_start);
|
||||
Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
} else {
|
||||
LogPrintf("Recreating the banlist database\n");
|
||||
m_banned = {};
|
||||
|
@ -58,13 +58,13 @@ void BanMan::DumpBanlist()
|
|||
SetBannedSetDirty(false);
|
||||
}
|
||||
|
||||
int64_t n_start = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
if (!m_ban_db.Write(banmap)) {
|
||||
SetBannedSetDirty(true);
|
||||
}
|
||||
|
||||
LogPrint(BCLog::NET, "Flushed %d banned node addresses/subnets to disk %dms\n", banmap.size(),
|
||||
GetTimeMillis() - n_start);
|
||||
Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
}
|
||||
|
||||
void BanMan::ClearBanned()
|
||||
|
|
|
@ -1452,7 +1452,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
};
|
||||
|
||||
uiInterface.InitMessage(_("Loading block index…").translated);
|
||||
const int64_t load_block_index_start_time = GetTimeMillis();
|
||||
const auto load_block_index_start_time{SteadyClock::now()};
|
||||
auto catch_exceptions = [](auto&& f) {
|
||||
try {
|
||||
return f();
|
||||
|
@ -1471,7 +1471,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
std::tie(status, error) = catch_exceptions([&]{ return VerifyLoadedChainstate(chainman, options);});
|
||||
if (status == node::ChainstateLoadStatus::SUCCESS) {
|
||||
fLoaded = true;
|
||||
LogPrintf(" block index %15dms\n", GetTimeMillis() - load_block_index_start_time);
|
||||
LogPrintf(" block index %15dms\n", Ticks<std::chrono::milliseconds>(SteadyClock::now() - load_block_index_start_time));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1487,12 +1487,12 @@ void CConnman::ThreadDNSAddressSeed()
|
|||
|
||||
void CConnman::DumpAddresses()
|
||||
{
|
||||
int64_t nStart = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
|
||||
DumpPeerAddresses(::gArgs, addrman);
|
||||
|
||||
LogPrint(BCLog::NET, "Flushed %d addresses to peers.dat %dms\n",
|
||||
addrman.size(), GetTimeMillis() - nStart);
|
||||
addrman.size(), Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
}
|
||||
|
||||
void CConnman::ProcessAddrFetch()
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
using SteadyClock = std::chrono::steady_clock;
|
||||
|
||||
static GlobalMutex g_rpc_warmup_mutex;
|
||||
static std::atomic<bool> g_rpc_running{false};
|
||||
static bool fRPCInWarmup GUARDED_BY(g_rpc_warmup_mutex) = true;
|
||||
|
|
|
@ -4267,7 +4267,7 @@ void CChainState::LoadExternalBlockFile(
|
|||
// Either both should be specified (-reindex), or neither (-loadblock).
|
||||
assert(!dbp == !blocks_with_unknown_parent);
|
||||
|
||||
int64_t nStart = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
|
||||
int nLoaded = 0;
|
||||
try {
|
||||
|
@ -4381,7 +4381,7 @@ void CChainState::LoadExternalBlockFile(
|
|||
} catch (const std::runtime_error& e) {
|
||||
AbortNode(std::string("System error: ") + e.what());
|
||||
}
|
||||
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
|
||||
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
}
|
||||
|
||||
void CChainState::CheckBlockIndex()
|
||||
|
|
|
@ -533,7 +533,7 @@ bool BerkeleyDatabase::Rewrite(const char* pszSkip)
|
|||
|
||||
void BerkeleyEnvironment::Flush(bool fShutdown)
|
||||
{
|
||||
int64_t nStart = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
// Flush log data to the actual data file on all files that are not in use
|
||||
LogPrint(BCLog::WALLETDB, "BerkeleyEnvironment::Flush: [%s] Flush(%s)%s\n", strPath, fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started");
|
||||
if (!fDbEnvInit)
|
||||
|
@ -561,7 +561,7 @@ void BerkeleyEnvironment::Flush(bool fShutdown)
|
|||
no_dbs_accessed = false;
|
||||
}
|
||||
}
|
||||
LogPrint(BCLog::WALLETDB, "BerkeleyEnvironment::Flush: Flush(%s)%s took %15dms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started", GetTimeMillis() - nStart);
|
||||
LogPrint(BCLog::WALLETDB, "BerkeleyEnvironment::Flush: Flush(%s)%s took %15dms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started", Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
if (fShutdown) {
|
||||
char** listp;
|
||||
if (no_dbs_accessed) {
|
||||
|
@ -591,14 +591,14 @@ bool BerkeleyDatabase::PeriodicFlush()
|
|||
|
||||
const std::string strFile = fs::PathToString(m_filename);
|
||||
LogPrint(BCLog::WALLETDB, "Flushing %s\n", strFile);
|
||||
int64_t nStart = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
|
||||
// Flush wallet file so it's self contained
|
||||
env->CloseDb(m_filename);
|
||||
env->CheckpointLSN(strFile);
|
||||
m_refcount = -1;
|
||||
|
||||
LogPrint(BCLog::WALLETDB, "Flushed %s %dms\n", strFile, GetTimeMillis() - nStart);
|
||||
LogPrint(BCLog::WALLETDB, "Flushed %s %dms\n", strFile, Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2756,7 +2756,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
ArgsManager& args = *Assert(context.args);
|
||||
const std::string& walletFile = database->Filename();
|
||||
|
||||
int64_t nStart = GetTimeMillis();
|
||||
const auto start{SteadyClock::now()};
|
||||
// TODO: Can't use std::make_shared because we need a custom deleter but
|
||||
// should be possible to use std::allocate_shared.
|
||||
const std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, args, std::move(database)), ReleaseWallet);
|
||||
|
@ -2973,7 +2973,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
walletInstance->m_spend_zero_conf_change = args.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
|
||||
walletInstance->m_signal_rbf = args.GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF);
|
||||
|
||||
walletInstance->WalletLogPrintf("Wallet completed loading in %15dms\n", GetTimeMillis() - nStart);
|
||||
walletInstance->WalletLogPrintf("Wallet completed loading in %15dms\n", Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
|
||||
// Try to top up keypool. No-op if the wallet is locked.
|
||||
walletInstance->TopUpKeyPool();
|
||||
|
|
Loading…
Add table
Reference in a new issue