[tarantool-patches] Re: [PATCH 12/18] histogram: add function for computing lower bound percentile estimate
Konstantin Osipov
kostja at tarantool.org
Mon Aug 20 14:29:16 MSK 2018
* Vladimir Davydov <vdavydov.dev at gmail.com> [18/08/16 23:03]:
> The value returned by histogram_percentile() is an upper bound estimate.
> This is fine for measuring latency, because we are interested in the
> worst, i.e. highest, observations, but doesn't suit particularly well
> if we want to keep track of the lowest observations, as it is the case
> with bandwidth. So this patch introduces histogram_percentile_lower(),
> a function that is similar to histogram_percentile(), but returns a
> lower bound estimate of the requested percentile.
> ---
I need you to explain to me what's going on here (add comment?), sorry.
> +int64_t
> +histogram_percentile_lower(struct histogram *hist, int pct)
> +{
> + size_t count = 0;
> +
> + for (size_t i = 0; i < hist->n_buckets; i++) {
> + count += hist->buckets[i].count;
> + if (count * 100 > hist->total * pct)
> + return hist->buckets[i > 0 ? i - 1 : 0].max;
> + }
> + return hist->max;
> +}
--
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov
More information about the Tarantool-patches
mailing list