mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Reduce SHAMapTreeNode copying during SHAMap unsharing:
In some code paths, we bump the SHAMap sequence number before we unshare. This forces SHAMapTreeNode to be copied. By making the ledger immutable we cause the unsharing to occur earlier, eliminating the copies.
This commit is contained in:
@@ -394,8 +394,9 @@ public:
|
||||
}
|
||||
if (didApply)
|
||||
{
|
||||
mCurrentLedger.set (ledger);
|
||||
getApp().getOPs ().pubProposedTransaction (ledger, txn, result);
|
||||
ledger->setImmutable (); // So the next line doesn't have to copy
|
||||
mCurrentLedger.set (ledger);
|
||||
getApp().getOPs ().pubProposedTransaction (ledger, txn, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1084,6 +1084,7 @@ void ApplicationImp::startNewLedger ()
|
||||
firstLedger->updateHash ();
|
||||
firstLedger->setClosed ();
|
||||
firstLedger->setAccepted ();
|
||||
firstLedger->setImmutable();
|
||||
m_ledgerMaster->pushLedger (firstLedger);
|
||||
|
||||
Ledger::pointer secondLedger = std::make_shared<Ledger> (true, std::ref (*firstLedger));
|
||||
|
||||
@@ -274,6 +274,7 @@ void
|
||||
SHAMap::setImmutable ()
|
||||
{
|
||||
assert (state_ != SHAMapState::Invalid);
|
||||
unshare ();
|
||||
state_ = SHAMapState::Immutable;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ SHAMap::snapShot (bool isMutable) const
|
||||
newMap.seq_ = seq_ + 1;
|
||||
newMap.root_ = root_;
|
||||
|
||||
if ((state_ != SHAMapState::Immutable) || !isMutable)
|
||||
if ((state_ != SHAMapState::Immutable) || isMutable)
|
||||
{
|
||||
// If either map may change, they cannot share nodes
|
||||
newMap.unshare ();
|
||||
|
||||
Reference in New Issue
Block a user