Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/evo/evodb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ void CEvoDBScopedCommitter::Rollback()
evoDB.RollbackCurTransaction();
}

CEvoDB::CEvoDB(size_t nCacheSize, bool fMemory, bool fWipe) :
db{fMemory ? "" : (gArgs.GetDataDirNet() / "evodb"), nCacheSize, fMemory, fWipe},
rootBatch{db},
rootDBTransaction{db, rootBatch},
CEvoDB::CEvoDB(bool fMemory, bool fWipe) :
db{std::make_unique<CDBWrapper>(fMemory ? "" : (gArgs.GetDataDirNet() / "evodb"), 64 << 20, fMemory, fWipe)},
rootBatch{*db},
rootDBTransaction{*db, rootBatch},
curDBTransaction{rootDBTransaction, rootDBTransaction}
{
}
Expand All @@ -59,7 +59,7 @@ bool CEvoDB::CommitRootTransaction()
LOCK(cs);
assert(curDBTransaction.IsClean());
rootDBTransaction.Commit();
bool ret = db.WriteBatch(rootBatch);
bool ret = db->WriteBatch(rootBatch);
rootBatch.Clear();
return ret;
}
Expand Down
8 changes: 4 additions & 4 deletions src/evo/evodb.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CEvoDB
public:
Mutex cs;
private:
CDBWrapper db;
std::unique_ptr<CDBWrapper> db;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every indirect access over unique_ptr means indirect memory access and that causes a bit slower performance.

Consider ccdd90e or something similar


using RootTransaction = CDBTransaction<CDBWrapper, CDBBatch>;
using CurTransaction = CDBTransaction<RootTransaction, RootTransaction>;
Expand All @@ -49,7 +49,7 @@ class CEvoDB
CEvoDB() = delete;
CEvoDB(const CEvoDB&) = delete;
CEvoDB& operator=(const CEvoDB&) = delete;
explicit CEvoDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
explicit CEvoDB(bool fMemory, bool fWipe);
~CEvoDB();

std::unique_ptr<CEvoDBScopedCommitter> BeginTransaction() EXCLUSIVE_LOCKS_REQUIRED(!cs)
Expand Down Expand Up @@ -94,7 +94,7 @@ class CEvoDB

CDBWrapper& GetRawDB()
{
return db;
return *db;
}

[[nodiscard]] size_t GetMemoryUsage() const
Expand All @@ -104,7 +104,7 @@ class CEvoDB

bool CommitRootTransaction() EXCLUSIVE_LOCKS_REQUIRED(!cs);

bool IsEmpty() { return db.IsEmpty(); }
bool IsEmpty() { return db->IsEmpty(); }

bool VerifyBestBlock(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(!cs);
void WriteBestBlock(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(!cs);
Expand Down
3 changes: 1 addition & 2 deletions src/node/chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,

LOCK(cs_main);

int64_t nEvoDbCache{64 * 1024 * 1024}; // TODO
evodb.reset();
evodb = std::make_unique<CEvoDB>(nEvoDbCache, false, fReset || fReindexChainState);
evodb = std::make_unique<CEvoDB>(/*fMemory=*/false, /*fWipe=*/fReset || fReindexChainState);

mnhf_manager.reset();
mnhf_manager = std::make_unique<CMNHFManager>(*evodb);
Expand Down
2 changes: 1 addition & 1 deletion src/test/util/setup_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
m_node.connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman); // Deterministic randomness for tests.

fCheckBlockIndex = true;
m_node.evodb = std::make_unique<CEvoDB>(1 << 20, true, true);
m_node.evodb = std::make_unique<CEvoDB>(/*fMemory=*/true, /*fWipe=*/true);
m_node.mnhf_manager = std::make_unique<CMNHFManager>(*m_node.evodb);
m_node.cpoolman = std::make_unique<CCreditPoolManager>(*m_node.evodb);
static bool noui_connected = false;
Expand Down