From 6a22cbceaf49d2902071fbc4235507eccd9f2629 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Mon, 3 Jul 2017 14:04:36 +0200 Subject: [PATCH] row_cache: Add metrics for operations on underlying reader --- read_context.hh | 13 +++++++++++-- row_cache.cc | 3 +++ row_cache.hh | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/read_context.hh b/read_context.hh index 7adde6ea54..a67fe09eb6 100644 --- a/read_context.hh +++ b/read_context.hh @@ -71,6 +71,9 @@ public: _range = std::move(*new_range); _last_key = {}; } + if (_reader) { + ++_cache._tracker._stats.underlying_recreations; + } auto& snap = _cache.snapshot_for_phase(phase); _reader = _cache.create_underlying_reader(_read_context, snap, _range); _reader_creation_phase = phase; @@ -90,8 +93,13 @@ public: _range = std::move(range); _last_key = { }; _new_last_key = { }; - if (_reader && _reader_creation_phase == phase) { - return _reader->fast_forward_to(_range); + if (_reader) { + if (_reader_creation_phase == phase) { + ++_cache._tracker._stats.underlying_partition_skips; + return _reader->fast_forward_to(_range); + } else { + ++_cache._tracker._stats.underlying_recreations; + } } _reader = _cache.create_underlying_reader(_read_context, snapshot, _range); _reader_creation_phase = phase; @@ -211,6 +219,7 @@ public: // Fast forwards the underlying streamed_mutation to given range. future<> fast_forward_to(position_range range) { return ensure_sm_created().then([this, range = std::move(range)] () mutable { + ++_cache._tracker._stats.underlying_row_skips; return _sm->fast_forward_to(std::move(range)); }); } diff --git a/row_cache.cc b/row_cache.cc index 77d6c770fa..350acb2642 100644 --- a/row_cache.cc +++ b/row_cache.cc @@ -111,6 +111,9 @@ cache_tracker::setup_metrics() { sm::make_derive("reads", sm::description("number of started reads"), _stats.reads), sm::make_derive("reads_with_misses", sm::description("number of reads which had to read from sstables"), _stats.reads_with_misses), sm::make_gauge("active_reads", sm::description("number of currently active reads"), [this] { return _stats.active_reads(); }), + sm::make_derive("sstable_reader_recreations", sm::description("number of times sstable reader was recreated due to memtable flush"), _stats.underlying_recreations), + sm::make_derive("sstable_partition_skips", sm::description("number of times sstable reader was fast forwarded across partitions"), _stats.underlying_partition_skips), + sm::make_derive("sstable_row_skips", sm::description("number of times sstable reader was fast forwarded within a partition"), _stats.underlying_row_skips), }); } diff --git a/row_cache.hh b/row_cache.hh index d1e2df1549..1425e95f65 100644 --- a/row_cache.hh +++ b/row_cache.hh @@ -200,6 +200,9 @@ public: uint64_t partitions; uint64_t modification_count; uint64_t mispopulations; + uint64_t underlying_recreations; + uint64_t underlying_partition_skips; + uint64_t underlying_row_skips; uint64_t reads; uint64_t reads_with_misses; uint64_t reads_done;