From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH v2 5/8] vinyl: add helpers for resetting statement counters Date: Sun, 16 Sep 2018 20:06:48 +0300 [thread overview] Message-ID: <d0c172b17ff1b981c13e288ef308c2baf5a89b86.1537115208.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1537115208.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1537115208.git.vdavydov.dev@gmail.com> Currently, we call memset() on vy_stmt_counter and vy_disk_stmt_counter directly, but that looks rather ugly, especially when a counter has a long name. Let's introduce helper functions for that. --- src/box/vinyl.c | 28 ++++++++++++++++++++-------- src/box/vy_stat.h | 13 +++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 197f16d6..2c479836 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -436,22 +436,34 @@ vinyl_index_reset_stat(struct index *index) struct vy_lsm_stat *stat = &lsm->stat; struct vy_cache_stat *cache_stat = &lsm->cache.stat; + /* Get/put */ stat->lookup = 0; latency_reset(&stat->latency); - memset(&stat->get, 0, sizeof(stat->get)); - memset(&stat->put, 0, sizeof(stat->put)); + vy_stmt_counter_reset(&stat->get); + vy_stmt_counter_reset(&stat->put); memset(&stat->upsert, 0, sizeof(stat->upsert)); + + /* Iterator */ memset(&stat->txw.iterator, 0, sizeof(stat->txw.iterator)); memset(&stat->memory.iterator, 0, sizeof(stat->memory.iterator)); memset(&stat->disk.iterator, 0, sizeof(stat->disk.iterator)); - memset(&stat->disk.dump, 0, sizeof(stat->disk.dump)); - memset(&stat->disk.compact, 0, sizeof(stat->disk.compact)); + /* Dump */ + stat->disk.dump.count = 0; + vy_stmt_counter_reset(&stat->disk.dump.in); + vy_disk_stmt_counter_reset(&stat->disk.dump.out); + + /* Compaction */ + stat->disk.compact.count = 0; + vy_disk_stmt_counter_reset(&stat->disk.compact.in); + vy_disk_stmt_counter_reset(&stat->disk.compact.out); + + /* Cache */ cache_stat->lookup = 0; - memset(&cache_stat->get, 0, sizeof(cache_stat->get)); - memset(&cache_stat->put, 0, sizeof(cache_stat->put)); - memset(&cache_stat->invalidate, 0, sizeof(cache_stat->invalidate)); - memset(&cache_stat->evict, 0, sizeof(cache_stat->evict)); + vy_stmt_counter_reset(&cache_stat->get); + vy_stmt_counter_reset(&cache_stat->put); + vy_stmt_counter_reset(&cache_stat->invalidate); + vy_stmt_counter_reset(&cache_stat->evict); } static void diff --git a/src/box/vy_stat.h b/src/box/vy_stat.h index 6d37e79f..83d3b8f9 100644 --- a/src/box/vy_stat.h +++ b/src/box/vy_stat.h @@ -32,6 +32,7 @@ */ #include <stdint.h> +#include <string.h> #include "latency.h" #include "tuple.h" @@ -204,6 +205,18 @@ vy_lsm_stat_destroy(struct vy_lsm_stat *stat) } static inline void +vy_stmt_counter_reset(struct vy_stmt_counter *c) +{ + memset(c, 0, sizeof(*c)); +} + +static inline void +vy_disk_stmt_counter_reset(struct vy_disk_stmt_counter *c) +{ + memset(c, 0, sizeof(*c)); +} + +static inline void vy_stmt_counter_acct_tuple(struct vy_stmt_counter *c, const struct tuple *tuple) { -- 2.11.0
next prev parent reply other threads:[~2018-09-16 17:06 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-09-16 17:06 [PATCH v2 0/8] vinyl: improve stats for throttling Vladimir Davydov 2018-09-16 17:06 ` [PATCH v2 1/8] vinyl: fix force compaction logic Vladimir Davydov 2018-09-19 1:43 ` Konstantin Osipov 2018-09-16 17:06 ` [PATCH v2 2/8] vinyl: update compact priority usual way on range split/coalesce Vladimir Davydov 2018-09-19 1:46 ` Konstantin Osipov 2018-09-16 17:06 ` [PATCH v2 3/8] vinyl: annotate info_table_end with comment Vladimir Davydov 2018-09-19 1:47 ` Konstantin Osipov 2018-09-16 17:06 ` [PATCH v2 4/8] vinyl: report pages and bytes_compressed in dump/compact in/out stats Vladimir Davydov 2018-09-19 1:48 ` Konstantin Osipov 2018-09-16 17:06 ` Vladimir Davydov [this message] 2018-09-19 1:49 ` [PATCH v2 5/8] vinyl: add helpers for resetting statement counters Konstantin Osipov 2018-09-16 17:06 ` [PATCH v2 6/8] vinyl: keep track of compaction queue length Vladimir Davydov 2018-09-19 1:53 ` Konstantin Osipov 2018-09-16 17:06 ` [PATCH v2 7/8] vinyl: factor out helpers for accounting dump/compaction Vladimir Davydov 2018-09-19 1:53 ` Konstantin Osipov 2018-09-16 17:06 ` [PATCH v2 8/8] vinyl: add global disk stats Vladimir Davydov 2018-09-19 1:56 ` Konstantin Osipov 2018-09-19 9:59 ` [PATCH v2 0/8] vinyl: improve stats for throttling Vladimir Davydov
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=d0c172b17ff1b981c13e288ef308c2baf5a89b86.1537115208.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v2 5/8] vinyl: add helpers for resetting statement counters' \ /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