Grow TxQ expected size quickly, shrink slowly (RIPD-1534):

* Stores recent history of "good" ledgers. Uses the maximum as the
  expected ledger size. When a large value drops off, use a 90%
  backoff to go down to to the new maximum.
* If consensus is unhealthy, wipe the history in addition to the current
  clamping.
* Include .md doc files in xcode and VS projects
This commit is contained in:
Edward Hennis
2017-09-21 19:05:50 -04:00
committed by Brad Chase
parent 0a48916d98
commit c11e186659
5 changed files with 38 additions and 9 deletions

View File

@@ -29,6 +29,7 @@
#include <boost/algorithm/clamp.hpp>
#include <limits>
#include <numeric>
#include <algorithm>
namespace ripple {
@@ -107,16 +108,32 @@ TxQ::FeeMetrics::update(Application& app,
// so clamp down on limits.
txnsExpected_ = boost::algorithm::clamp(feeLevels.size(),
minimumTxnCount_, targetTxnCount_);
recentTxnCounts_.clear();
}
else if (feeLevels.size() > txnsExpected_ ||
feeLevels.size() > targetTxnCount_)
{
recentTxnCounts_.push_back(feeLevels.size());
auto const iter = std::max_element(recentTxnCounts_.begin(),
recentTxnCounts_.end());
BOOST_ASSERT(iter != recentTxnCounts_.end());
auto const next = [&]
{
// Grow quickly: If the max_element is >= the
// current size limit, use it.
if (*iter >= txnsExpected_)
return *iter;
// Shrink slowly: If the max_element is < the
// current size limit, use a limit that is
// 90% of the way from max_element to the
// current size limit.
return (txnsExpected_ * 9 + *iter) / 10;
}();
// Ledgers are processing in a timely manner,
// so keep the limit high, but don't let it
// grow without bound.
txnsExpected_ = maximumTxnCount_ ?
std::min(feeLevels.size(), *maximumTxnCount_) :
feeLevels.size();
txnsExpected_ = std::min(next,
maximumTxnCount_.value_or(next));
}
if (feeLevels.empty())