Skip to content

Commit

Permalink
#1890 format
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed May 14, 2024
1 parent 0c6b994 commit c56e96a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion libdevcore/LevelDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class LevelDB : public DatabaseFace {
static std::atomic< uint64_t > g_keyDeletesStats;
// count of the keys that are scheduled to be deleted but are not yet deleted
static std::atomic< uint64_t > g_keysToBeDeletedStats;
static uint64_t getCurrentTimeMs();

private:
std::unique_ptr< leveldb::DB > m_db;
Expand Down Expand Up @@ -123,7 +124,6 @@ class LevelDB : public DatabaseFace {
}
};
void openDBInstanceUnsafe();
uint64_t getCurrentTimeMs();
void reopenDataBaseIfNeeded();
};

Expand Down
2 changes: 1 addition & 1 deletion libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ size_t Client::syncTransactions(

#ifdef HISTORIC_STATE
LOG( m_logger ) << "HSCT: "
<< m_working.mutableState().mutableHistoricState().getBlockCommitTime();
<< m_working.mutableState().mutableHistoricState().getAndResetBlockCommitTime();
#endif
return goodReceipts;
}
Expand Down
20 changes: 8 additions & 12 deletions libhistoric/HistoricState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ HistoricState::HistoricState( HistoricState const& _s )
m_nonExistingAccountsCache( _s.m_nonExistingAccountsCache ),
m_unrevertablyTouched( _s.m_unrevertablyTouched ),
m_accountStartNonce( _s.m_accountStartNonce ),
m_blockCommitTimeMs( _s.m_blockCommitTimeMs ) {}
m_totalTimeSpentInStateCommitsPerBlock( _s.m_totalTimeSpentInStateCommitsPerBlock ) {}

OverlayDB HistoricState::openDB(
fs::path const& _basePath, h256 const& _genesisHash, WithExisting _we ) {
Expand Down Expand Up @@ -138,7 +138,7 @@ HistoricState& HistoricState::operator=( HistoricState const& _s ) {
m_nonExistingAccountsCache = _s.m_nonExistingAccountsCache;
m_unrevertablyTouched = _s.m_unrevertablyTouched;
m_accountStartNonce = _s.m_accountStartNonce;
m_blockCommitTimeMs = _s.m_blockCommitTimeMs;
m_totalTimeSpentInStateCommitsPerBlock = _s.m_totalTimeSpentInStateCommitsPerBlock;
return *this;
}

Expand Down Expand Up @@ -196,23 +196,19 @@ void HistoricState::clearCacheIfTooLarge() const {
}

void HistoricState::commitExternalChanges( AccountMap const& _accountMap ) {
boost::chrono::high_resolution_clock::time_point historicStateStart =
boost::chrono::high_resolution_clock::now();
auto historicStateStart = dev::db::LevelDB::getCurrentTimeMs();
commitExternalChangesIntoTrieDB( _accountMap, m_state );
m_state.db()->commit();
m_changeLog.clear();
m_cache.clear();
m_unchangedCacheEntries.clear();
boost::chrono::high_resolution_clock::time_point historicStateFinish =
boost::chrono::high_resolution_clock::now();
m_blockCommitTimeMs += boost::chrono::duration_cast< boost::chrono::milliseconds >(
historicStateFinish - historicStateStart )
.count();
auto historicStateFinish = dev::db::LevelDB::getCurrentTimeMs();
m_totalTimeSpentInStateCommitsPerBlock += historicStateFinish - historicStateStart;
}

uint64_t HistoricState::getBlockCommitTime() {
uint64_t retVal = m_blockCommitTimeMs;
m_blockCommitTimeMs = 0;
uint64_t HistoricState::getAndResetBlockCommitTime() {
uint64_t retVal = m_totalTimeSpentInStateCommitsPerBlock;
m_totalTimeSpentInStateCommitsPerBlock = 0;
return retVal;
}

Expand Down
4 changes: 2 additions & 2 deletions libhistoric/HistoricState.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class HistoricState {

void setRootFromDB();

uint64_t getBlockCommitTime();
uint64_t getAndResetBlockCommitTime();

private:
/// Turns all "touched" empty accounts into non-alive accounts.
Expand Down Expand Up @@ -348,7 +348,7 @@ class HistoricState {
AddressHash commitExternalChangesIntoTrieDB(
AccountMap const& _cache, SecureTrieDB< Address, OverlayDB >& _state );

uint64_t m_blockCommitTimeMs = 0;
uint64_t m_totalTimeSpentInStateCommitsPerBlock = 0;
};

std::ostream& operator<<( std::ostream& _out, HistoricState const& _s );
Expand Down

0 comments on commit c56e96a

Please sign in to comment.