From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 5/8] vinyl: add helpers for resetting statement counters Date: Sun, 16 Sep 2018 20:06:48 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: 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 +#include #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