Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH v2] vinyl: improve latency stat
Date: Wed, 21 Mar 2018 16:00:21 +0300	[thread overview]
Message-ID: <e585c0cfebfaed409d352010f865b88422b1da8e.1521636468.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <8dcfab28672553632a1cd9bc12e4e1adfd4727a5.1519992862.git.vdavydov.dev@gmail.com>

To facilitate performance analysis, let's report not only 99th
percentile, but also 50th, 75th, 90th, and 95th. Also, let's add
microsecond-granular buckets to the latency histogram.

Closes #3207
---
https://github.com/tarantool/tarantool/tree/gh-3207-vy-improve-latency-stat

Changes in v2:
 - Do not use clock_monotonic() for checking latency as it is
   much more expensive then ev_monotonic_now(), even on Linux
   with VDSO enabled (25 ns vs 1ns).

 src/box/vinyl.c |  9 ++++++++-
 src/latency.c   | 13 ++++++-------
 src/latency.h   |  3 ++-
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 9cc14f72..306a7a4d 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -412,7 +412,14 @@ vinyl_index_info(struct index *base, struct info_handler *h)
 	info_append_int(h, "lookup", stat->lookup);
 	vy_info_append_stmt_counter(h, "get", &stat->get);
 	vy_info_append_stmt_counter(h, "put", &stat->put);
-	info_append_double(h, "latency", latency_get(&stat->latency));
+
+	info_table_begin(h, "latency");
+	info_append_double(h, "p50", latency_get(&stat->latency, 50));
+	info_append_double(h, "p75", latency_get(&stat->latency, 75));
+	info_append_double(h, "p90", latency_get(&stat->latency, 90));
+	info_append_double(h, "p95", latency_get(&stat->latency, 95));
+	info_append_double(h, "p99", latency_get(&stat->latency, 99));
+	info_table_end(h);
 
 	info_table_begin(h, "upsert");
 	info_append_int(h, "squashed", stat->upsert.squashed);
diff --git a/src/latency.c b/src/latency.c
index 02b60396..c8b9d841 100644
--- a/src/latency.c
+++ b/src/latency.c
@@ -40,15 +40,15 @@ enum {
 	USEC_PER_SEC		= 1000000,
 };
 
-enum {
-	LATENCY_PERCENTILE	= 99,
-};
-
 int
 latency_create(struct latency *latency)
 {
 	enum { US = 1, MS = USEC_PER_MSEC, S = USEC_PER_SEC };
 	static int64_t buckets[] = {
+		  1 * US,   2 * US,   3 * US,   4 * US,   5 * US,   6 * US,
+		  7 * US,   8 * US,   9 * US,
+		 10 * US,  20 * US,  30 * US,  40 * US,  50 * US,  60 * US,
+		 70 * US,  80 * US,  90 * US,
 		100 * US, 200 * US, 300 * US, 400 * US, 500 * US, 600 * US,
 		700 * US, 800 * US, 900 * US,
 		  1 * MS,   2 * MS,   3 * MS,   4 * MS,   5 * MS,   6 * MS,
@@ -90,9 +90,8 @@ latency_collect(struct latency *latency, double value)
 }
 
 double
-latency_get(struct latency *latency)
+latency_get(struct latency *latency, int pct)
 {
-	int64_t value_usec = histogram_percentile(latency->histogram,
-						  LATENCY_PERCENTILE);
+	int64_t value_usec = histogram_percentile(latency->histogram, pct);
 	return (double)value_usec / USEC_PER_SEC;
 }
diff --git a/src/latency.h b/src/latency.h
index 2170310c..e43822d4 100644
--- a/src/latency.h
+++ b/src/latency.h
@@ -72,8 +72,9 @@ latency_collect(struct latency *latency, double value);
 
 /**
  * Get accumulated latency value, in seconds.
+ * Returns @pct-th percentile of all observations.
  */
 double
-latency_get(struct latency *latency);
+latency_get(struct latency *latency, int pct);
 
 #endif /* TARANTOOL_LATENCY_H_INCLUDED */
-- 
2.11.0

           reply	other threads:[~2018-03-21 13:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <8dcfab28672553632a1cd9bc12e4e1adfd4727a5.1519992862.git.vdavydov.dev@gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e585c0cfebfaed409d352010f865b88422b1da8e.1521636468.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2] vinyl: improve latency stat' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox