Control transaction dispatch rate:

Do not dispatch a transaction received from a peer for
processing, if it has already been dispatched within the
past ten seconds.

Increase the number of transaction handlers that can be in
flight in the job queue and decrease the relative cost for
peers to share transaction and ledger data.

Additionally, make better use of resources by adjusting the
number of threads we initialize, by reverting commit
68b8ffdb63.
This commit is contained in:
Mark Travis
2017-12-09 17:10:54 -08:00
committed by Nikolaos D. Bougalis
parent 6dc79c23ed
commit fbfb4bd74e
8 changed files with 56 additions and 42 deletions

View File

@@ -118,12 +118,21 @@ private:
return ++recoveries_ % limit != 0;
}
bool shouldProcess(Stopwatch::time_point now, std::chrono::seconds interval)
{
if (processed_ && ((*processed_ + interval) > now))
return false;
processed_.emplace (now);
return true;
}
private:
int flags_ = 0;
std::set <PeerShortID> peers_;
// This could be generalized to a map, if more
// than one flag needs to expire independently.
boost::optional<Stopwatch::time_point> relayed_;
boost::optional<Stopwatch::time_point> processed_;
std::uint32_t recoveries_ = 0;
};
@@ -161,6 +170,10 @@ public:
bool addSuppressionPeer (uint256 const& key, PeerShortID peer,
int& flags);
// Add a peer suppression and return whether the entry should be processed
bool shouldProcess (uint256 const& key, PeerShortID peer,
int& flags, Stopwatch::time_point now, std::chrono::seconds interval);
/** Set the flags on a hash.
@return `true` if the flags were changed. `false` if unchanged.