From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2] vinyl: improve latency stat Date: Wed, 21 Mar 2018 16:00:21 +0300 Message-Id: In-Reply-To: <8dcfab28672553632a1cd9bc12e4e1adfd4727a5.1519992862.git.vdavydov.dev@gmail.com> References: <8dcfab28672553632a1cd9bc12e4e1adfd4727a5.1519992862.git.vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: 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