From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id E8E4228120 for ; Mon, 20 Aug 2018 07:29:18 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tf6tG2meJfrz for ; Mon, 20 Aug 2018 07:29:18 -0400 (EDT) Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id A2DE427986 for ; Mon, 20 Aug 2018 07:29:18 -0400 (EDT) Received: from [185.6.245.178] (port=1130 helo=atlas.local) by smtp51.i.mail.ru with esmtpa (envelope-from ) id 1friN3-0002Rj-4u for tarantool-patches@freelists.org; Mon, 20 Aug 2018 14:29:17 +0300 Date: Mon, 20 Aug 2018 14:29:16 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH 12/18] histogram: add function for computing lower bound percentile estimate Message-ID: <20180820112916.GO8716@chai> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org * 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. > +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