summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Branca <chewbranca@apache.org>2021-09-02 11:17:20 -0700
committerRussell Branca <chewbranca@apache.org>2021-09-02 11:17:20 -0700
commitbbe2e20a1388e67447f82c2be981de2ed115d11d (patch)
tree871b0e12a1e0c02243527f075710d3b1aa61648d
parent7a09fb0ac0728e0ec05ce0bf32d7e7f417b9d735 (diff)
downloadcouchdb-bbe2e20a1388e67447f82c2be981de2ed115d11d.tar.gz
Add couch_file cache metrics
-rw-r--r--src/couch/priv/stats_descriptions.cfg12
-rw-r--r--src/couch/src/couch_file.erl3
2 files changed, 15 insertions, 0 deletions
diff --git a/src/couch/priv/stats_descriptions.cfg b/src/couch/priv/stats_descriptions.cfg
index 7c8fd94cb..57ee39f85 100644
--- a/src/couch/priv/stats_descriptions.cfg
+++ b/src/couch/priv/stats_descriptions.cfg
@@ -290,6 +290,18 @@
{type, histogram},
{desc, <<"duration of validate_doc_update function calls">>}
]}.
+{[couchdb, couch_file, cache_misses], [
+ {type, counter},
+ {desc, <<"number of couch_file cache misses">>}
+]}.
+{[couchdb, couch_file, cache_hits], [
+ {type, counter},
+ {desc, <<"number of couch_file cache hits">>}
+]}.
+{[couchdb, couch_file, cache_opens], [
+ {type, counter},
+ {desc, <<"number of new couch_file caches opened">>}
+]}.
{[pread, exceed_eof], [
{type, counter},
{desc, <<"number of the attempts to read beyond end of db file">>}
diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index a6eeef5c1..a3856b915 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -192,8 +192,10 @@ pread_binary(Fd, Pos) ->
pread_iolist(Fd, Pos) ->
case load_from_cache(Fd, Pos) of
{ok, IoList, Md5} ->
+ couch_stats:increment_counter([couchdb, couch_file, cache_hits]),
{ok, verify_md5(Fd, Pos, IoList, Md5)};
missing ->
+ couch_stats:increment_counter([couchdb, couch_file, cache_misses]),
case ioq:call(Fd, {pread_iolist, Pos}, erlang:get(io_priority)) of
{ok, IoList, Md5} ->
{ok, verify_md5(Fd, Pos, IoList, Md5)};
@@ -433,6 +435,7 @@ init({Filepath, Options, ReturnPid, Ref}) ->
ShouldCache = config:get_boolean("couchdb", "couch_file_cache", true),
Tab = case ShouldCache of
true ->
+ couch_stats:increment_counter([couchdb, couch_file, cache_opens]),
ets:new(?MODULE, [set, protected, {read_concurrency, true}]);
false ->
undefined