Skip to content

Commit

Permalink
Miscellaneous Improvements:
Browse files Browse the repository at this point in the history
- Adjust default tree cache sizing
- Various micro-optimizations
  • Loading branch information
nbougalis authored and manojsdoshi committed Mar 30, 2022
1 parent 1823506 commit d66d960
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
26 changes: 13 additions & 13 deletions src/ripple/core/impl/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,19 @@ sizedItems
// what they control and whether there exists an explicit
// config option that can be used to override the default.

// tiny small medium large huge
{SizedItem::sweepInterval, {{ 10, 30, 60, 90, 120 }}},
{SizedItem::treeCacheSize, {{ 128000, 256000, 512000, 768000, 2048000 }}},
{SizedItem::treeCacheAge, {{ 30, 60, 90, 120, 900 }}},
{SizedItem::ledgerSize, {{ 32, 128, 256, 384, 768 }}},
{SizedItem::ledgerAge, {{ 30, 90, 180, 240, 900 }}},
{SizedItem::ledgerFetch, {{ 2, 3, 4, 5, 8 }}},
{SizedItem::hashNodeDBCache, {{ 4, 12, 24, 64, 128 }}},
{SizedItem::txnDBCache, {{ 4, 12, 24, 64, 128 }}},
{SizedItem::lgrDBCache, {{ 4, 8, 16, 32, 128 }}},
{SizedItem::openFinalLimit, {{ 8, 16, 32, 64, 128 }}},
{SizedItem::burstSize, {{ 4, 8, 16, 32, 48 }}},
{SizedItem::ramSizeGB, {{ 8, 12, 16, 24, 32 }}},
// tiny small medium large huge
{SizedItem::sweepInterval, {{ 10, 30, 60, 90, 120 }}},
{SizedItem::treeCacheSize, {{ 262144, 524288, 2097152, 4194304, 8388608 }}},
{SizedItem::treeCacheAge, {{ 30, 60, 90, 120, 900 }}},
{SizedItem::ledgerSize, {{ 32, 128, 256, 384, 768 }}},
{SizedItem::ledgerAge, {{ 30, 90, 180, 240, 900 }}},
{SizedItem::ledgerFetch, {{ 2, 3, 4, 5, 8 }}},
{SizedItem::hashNodeDBCache, {{ 4, 12, 24, 64, 128 }}},
{SizedItem::txnDBCache, {{ 4, 12, 24, 64, 128 }}},
{SizedItem::lgrDBCache, {{ 4, 8, 16, 32, 128 }}},
{SizedItem::openFinalLimit, {{ 8, 16, 32, 64, 128 }}},
{SizedItem::burstSize, {{ 4, 8, 16, 32, 48 }}},
{SizedItem::ramSizeGB, {{ 8, 12, 16, 24, 32 }}},
}};

// Ensure that the order of entries in the table corresponds to the
Expand Down
53 changes: 34 additions & 19 deletions src/ripple/overlay/impl/PeerImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ PeerImp::fail(std::string const& reason)
return post(
strand_,
std::bind(
(void(Peer::*)(std::string const&)) & PeerImp::fail,
(void (Peer::*)(std::string const&)) & PeerImp::fail,
shared_from_this(),
reason));
if (journal_.active(beast::severities::kWarning) && socket_.is_open())
Expand Down Expand Up @@ -1587,17 +1587,18 @@ PeerImp::handleTransaction(
}
}

if (app_.getJobQueue().getJobCount(jtTRANSACTION) >
if (app_.getLedgerMaster().getValidatedLedgerAge() > 4min)
{
JLOG(p_journal_.trace())
<< "No new transactions until synchronized";
}
else if (
app_.getJobQueue().getJobCount(jtTRANSACTION) >
app_.config().MAX_TRANSACTIONS)
{
overlay_.incJqTransOverflow();
JLOG(p_journal_.info()) << "Transaction queue is full";
}
else if (app_.getLedgerMaster().getValidatedLedgerAge() > 4min)
{
JLOG(p_journal_.trace())
<< "No new transactions until synchronized";
}
else
{
app_.getJobQueue().addJob(
Expand Down Expand Up @@ -2573,6 +2574,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
return;

auto key = sha512Half(makeSlice(m->validation()));

if (auto [added, relayed] =
app_.getHashRouter().addSuppressionPeerWithStatus(key, id_);
!added)
Expand All @@ -2592,22 +2594,36 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
if (!isTrusted && (tracking_.load() == Tracking::diverged))
{
JLOG(p_journal_.debug())
<< "Validation: dropping untrusted from diverged peer";
<< "Dropping untrusted validation from diverged peer";
}
if (isTrusted || cluster() || !app_.getFeeTrack().isLoadedLocal())
else if (isTrusted || !app_.getFeeTrack().isLoadedLocal())
{
std::string const name = [isTrusted, val]() {
std::string ret =
isTrusted ? "Trusted validation" : "Untrusted validation";

#ifdef DEBUG
ret += " " +
std::to_string(val->getFieldU32(sfLedgerSequence)) + ": " +
to_string(val->getNodeID());
#endif

return ret;
}();

std::weak_ptr<PeerImp> weak = shared_from_this();
app_.getJobQueue().addJob(
isTrusted ? jtVALIDATION_t : jtVALIDATION_ut,
"recvValidation->checkValidation",
[weak, val, m]() {
name,
[weak, val, m, key]() {
if (auto peer = weak.lock())
peer->checkValidation(val, m);
peer->checkValidation(val, key, m);
});
}
else
{
JLOG(p_journal_.debug()) << "Validation: Dropping UNTRUSTED (load)";
JLOG(p_journal_.debug())
<< "Dropping untrusted validation for load";
}
}
catch (std::exception const& e)
Expand Down Expand Up @@ -3152,12 +3168,13 @@ PeerImp::checkPropose(
void
PeerImp::checkValidation(
std::shared_ptr<STValidation> const& val,
uint256 const& key,
std::shared_ptr<protocol::TMValidation> const& packet)
{
if (!cluster() && !val->isValid())
if (!val->isValid())
{
JLOG(p_journal_.debug()) << "Validation forwarded by peer is invalid";
charge(Resource::feeInvalidRequest);
charge(Resource::feeInvalidSignature);
return;
}

Expand All @@ -3167,18 +3184,16 @@ PeerImp::checkValidation(
if (app_.getOPs().recvValidation(val, std::to_string(id())) ||
cluster())
{
auto const suppression =
sha512Half(makeSlice(val->getSerialized()));
// haveMessage contains peers, which are suppressed; i.e. the peers
// are the source of the message, consequently the message should
// not be relayed to these peers. But the message must be counted
// as part of the squelch logic.
auto haveMessage =
overlay_.relay(*packet, suppression, val->getSignerPublic());
overlay_.relay(*packet, key, val->getSignerPublic());
if (reduceRelayReady() && !haveMessage.empty())
{
overlay_.updateSlotAndSquelch(
suppression,
key,
val->getSignerPublic(),
std::move(haveMessage),
protocol::mtVALIDATION);
Expand Down
1 change: 1 addition & 0 deletions src/ripple/overlay/impl/PeerImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ class PeerImp : public Peer,
void
checkValidation(
std::shared_ptr<STValidation> const& val,
uint256 const& key,
std::shared_ptr<protocol::TMValidation> const& packet);

void
Expand Down

0 comments on commit d66d960

Please sign in to comment.