From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 24 Aug 2018 11:30:08 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] Re: [PATCH 12/18] histogram: add function for computing lower bound percentile estimate Message-ID: <20180824083008.rig2o75iiehb7kpi@esperanza> References: <20180820112916.GO8716@chai> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180820112916.GO8716@chai> To: Konstantin Osipov Cc: tarantool-patches@freelists.org List-ID: On Mon, Aug 20, 2018 at 02:29:16PM +0300, Konstantin Osipov wrote: > * Vladimir Davydov [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. There's a comment to the function declaration. Sorry, but I don't quite understand what else you want me to write here. This function simply calculates a histogram percentile, similarly to histogram_percentile(), but uses the lower bound estimate. I don't know what else to say... > > > > +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; > > +}