Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH v2] vinyl: improve latency stat
       [not found] <8dcfab28672553632a1cd9bc12e4e1adfd4727a5.1519992862.git.vdavydov.dev@gmail.com>
@ 2018-03-21 13:00 ` Vladimir Davydov
  0 siblings, 0 replies; only message in thread
From: Vladimir Davydov @ 2018-03-21 13:00 UTC (permalink / raw)
  To: kostja; +Cc: tarantool-patches

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-21 13:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <8dcfab28672553632a1cd9bc12e4e1adfd4727a5.1519992862.git.vdavydov.dev@gmail.com>
2018-03-21 13:00 ` [PATCH v2] vinyl: improve latency stat Vladimir Davydov

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