Skip to content

Commit d66d960

Browse files
nbougalismanojsdoshi
authored andcommitted
Miscellaneous Improvements:
- Adjust default tree cache sizing - Various micro-optimizations
1 parent 1823506 commit d66d960

File tree

3 files changed

+48
-32
lines changed

3 files changed

+48
-32
lines changed

src/ripple/core/impl/Config.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,19 @@ sizedItems
115115
// what they control and whether there exists an explicit
116116
// config option that can be used to override the default.
117117

118-
// tiny small medium large huge
119-
{SizedItem::sweepInterval, {{ 10, 30, 60, 90, 120 }}},
120-
{SizedItem::treeCacheSize, {{ 128000, 256000, 512000, 768000, 2048000 }}},
121-
{SizedItem::treeCacheAge, {{ 30, 60, 90, 120, 900 }}},
122-
{SizedItem::ledgerSize, {{ 32, 128, 256, 384, 768 }}},
123-
{SizedItem::ledgerAge, {{ 30, 90, 180, 240, 900 }}},
124-
{SizedItem::ledgerFetch, {{ 2, 3, 4, 5, 8 }}},
125-
{SizedItem::hashNodeDBCache, {{ 4, 12, 24, 64, 128 }}},
126-
{SizedItem::txnDBCache, {{ 4, 12, 24, 64, 128 }}},
127-
{SizedItem::lgrDBCache, {{ 4, 8, 16, 32, 128 }}},
128-
{SizedItem::openFinalLimit, {{ 8, 16, 32, 64, 128 }}},
129-
{SizedItem::burstSize, {{ 4, 8, 16, 32, 48 }}},
130-
{SizedItem::ramSizeGB, {{ 8, 12, 16, 24, 32 }}},
118+
// tiny small medium large huge
119+
{SizedItem::sweepInterval, {{ 10, 30, 60, 90, 120 }}},
120+
{SizedItem::treeCacheSize, {{ 262144, 524288, 2097152, 4194304, 8388608 }}},
121+
{SizedItem::treeCacheAge, {{ 30, 60, 90, 120, 900 }}},
122+
{SizedItem::ledgerSize, {{ 32, 128, 256, 384, 768 }}},
123+
{SizedItem::ledgerAge, {{ 30, 90, 180, 240, 900 }}},
124+
{SizedItem::ledgerFetch, {{ 2, 3, 4, 5, 8 }}},
125+
{SizedItem::hashNodeDBCache, {{ 4, 12, 24, 64, 128 }}},
126+
{SizedItem::txnDBCache, {{ 4, 12, 24, 64, 128 }}},
127+
{SizedItem::lgrDBCache, {{ 4, 8, 16, 32, 128 }}},
128+
{SizedItem::openFinalLimit, {{ 8, 16, 32, 64, 128 }}},
129+
{SizedItem::burstSize, {{ 4, 8, 16, 32, 48 }}},
130+
{SizedItem::ramSizeGB, {{ 8, 12, 16, 24, 32 }}},
131131
}};
132132

133133
// Ensure that the order of entries in the table corresponds to the

src/ripple/overlay/impl/PeerImp.cpp

+34-19
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ PeerImp::fail(std::string const& reason)
603603
return post(
604604
strand_,
605605
std::bind(
606-
(void(Peer::*)(std::string const&)) & PeerImp::fail,
606+
(void (Peer::*)(std::string const&)) & PeerImp::fail,
607607
shared_from_this(),
608608
reason));
609609
if (journal_.active(beast::severities::kWarning) && socket_.is_open())
@@ -1587,17 +1587,18 @@ PeerImp::handleTransaction(
15871587
}
15881588
}
15891589

1590-
if (app_.getJobQueue().getJobCount(jtTRANSACTION) >
1590+
if (app_.getLedgerMaster().getValidatedLedgerAge() > 4min)
1591+
{
1592+
JLOG(p_journal_.trace())
1593+
<< "No new transactions until synchronized";
1594+
}
1595+
else if (
1596+
app_.getJobQueue().getJobCount(jtTRANSACTION) >
15911597
app_.config().MAX_TRANSACTIONS)
15921598
{
15931599
overlay_.incJqTransOverflow();
15941600
JLOG(p_journal_.info()) << "Transaction queue is full";
15951601
}
1596-
else if (app_.getLedgerMaster().getValidatedLedgerAge() > 4min)
1597-
{
1598-
JLOG(p_journal_.trace())
1599-
<< "No new transactions until synchronized";
1600-
}
16011602
else
16021603
{
16031604
app_.getJobQueue().addJob(
@@ -2573,6 +2574,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
25732574
return;
25742575

25752576
auto key = sha512Half(makeSlice(m->validation()));
2577+
25762578
if (auto [added, relayed] =
25772579
app_.getHashRouter().addSuppressionPeerWithStatus(key, id_);
25782580
!added)
@@ -2592,22 +2594,36 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
25922594
if (!isTrusted && (tracking_.load() == Tracking::diverged))
25932595
{
25942596
JLOG(p_journal_.debug())
2595-
<< "Validation: dropping untrusted from diverged peer";
2597+
<< "Dropping untrusted validation from diverged peer";
25962598
}
2597-
if (isTrusted || cluster() || !app_.getFeeTrack().isLoadedLocal())
2599+
else if (isTrusted || !app_.getFeeTrack().isLoadedLocal())
25982600
{
2601+
std::string const name = [isTrusted, val]() {
2602+
std::string ret =
2603+
isTrusted ? "Trusted validation" : "Untrusted validation";
2604+
2605+
#ifdef DEBUG
2606+
ret += " " +
2607+
std::to_string(val->getFieldU32(sfLedgerSequence)) + ": " +
2608+
to_string(val->getNodeID());
2609+
#endif
2610+
2611+
return ret;
2612+
}();
2613+
25992614
std::weak_ptr<PeerImp> weak = shared_from_this();
26002615
app_.getJobQueue().addJob(
26012616
isTrusted ? jtVALIDATION_t : jtVALIDATION_ut,
2602-
"recvValidation->checkValidation",
2603-
[weak, val, m]() {
2617+
name,
2618+
[weak, val, m, key]() {
26042619
if (auto peer = weak.lock())
2605-
peer->checkValidation(val, m);
2620+
peer->checkValidation(val, key, m);
26062621
});
26072622
}
26082623
else
26092624
{
2610-
JLOG(p_journal_.debug()) << "Validation: Dropping UNTRUSTED (load)";
2625+
JLOG(p_journal_.debug())
2626+
<< "Dropping untrusted validation for load";
26112627
}
26122628
}
26132629
catch (std::exception const& e)
@@ -3152,12 +3168,13 @@ PeerImp::checkPropose(
31523168
void
31533169
PeerImp::checkValidation(
31543170
std::shared_ptr<STValidation> const& val,
3171+
uint256 const& key,
31553172
std::shared_ptr<protocol::TMValidation> const& packet)
31563173
{
3157-
if (!cluster() && !val->isValid())
3174+
if (!val->isValid())
31583175
{
31593176
JLOG(p_journal_.debug()) << "Validation forwarded by peer is invalid";
3160-
charge(Resource::feeInvalidRequest);
3177+
charge(Resource::feeInvalidSignature);
31613178
return;
31623179
}
31633180

@@ -3167,18 +3184,16 @@ PeerImp::checkValidation(
31673184
if (app_.getOPs().recvValidation(val, std::to_string(id())) ||
31683185
cluster())
31693186
{
3170-
auto const suppression =
3171-
sha512Half(makeSlice(val->getSerialized()));
31723187
// haveMessage contains peers, which are suppressed; i.e. the peers
31733188
// are the source of the message, consequently the message should
31743189
// not be relayed to these peers. But the message must be counted
31753190
// as part of the squelch logic.
31763191
auto haveMessage =
3177-
overlay_.relay(*packet, suppression, val->getSignerPublic());
3192+
overlay_.relay(*packet, key, val->getSignerPublic());
31783193
if (reduceRelayReady() && !haveMessage.empty())
31793194
{
31803195
overlay_.updateSlotAndSquelch(
3181-
suppression,
3196+
key,
31823197
val->getSignerPublic(),
31833198
std::move(haveMessage),
31843199
protocol::mtVALIDATION);

src/ripple/overlay/impl/PeerImp.h

+1
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ class PeerImp : public Peer,
626626
void
627627
checkValidation(
628628
std::shared_ptr<STValidation> const& val,
629+
uint256 const& key,
629630
std::shared_ptr<protocol::TMValidation> const& packet);
630631

631632
void

0 commit comments

Comments
 (0)