MXS-1777 Tune code for cases with slow, or new servers.

Changes that allow slow or new servers to quickly apply samples towards the
server average. The most important changes are to not ignore the first N samples,
and apply an average to the server as soon as there is one available.
The new ResponseStat::make_valid() will use filter samples to add an average,
if no averages have yet been added, even if the number of  filter samples is less
than the filter limit.
This commit is contained in:
Niclas Antti
2018-09-06 08:39:11 +03:00
parent 0e5d827f7a
commit fa7ec95069
5 changed files with 41 additions and 23 deletions

View File

@ -70,8 +70,11 @@ EMAverage::EMAverage(double min_alpha, double max_alpha, int sample_max) :
void EMAverage::add(double ave, int num_samples)
{
// Give more weight to initial samples.
int sample_max = std::min(m_num_samples ? m_num_samples : 1, m_sample_max);
double alpha = m_min_alpha + m_max_alpha *
std::min(double(num_samples) / m_sample_max, 1.0);
std::min(double(num_samples) / sample_max, 1.0);
m_num_samples += num_samples;
if (m_num_samples == num_samples)