summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-11-11 17:06:42 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-11-11 17:06:42 +0000
commit54483ee88d6516caa56ced399e5a8cea7a72a1e3 (patch)
tree79c56c40f497ab9ee0da033028c1ce97557f33e3
parent0e338d6fc8638f8eadd594ec72c1e766f3350958 (diff)
downloadrabbitmq-server-54483ee88d6516caa56ced399e5a8cea7a72a1e3.tar.gz
Emit stats on FHC recycling.bug24781
-rw-r--r--src/file_handle_cache.erl12
-rw-r--r--src/file_handle_cache_stats.erl10
2 files changed, 15 insertions, 7 deletions
diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl
index 3364c3ae..65f3f45b 100644
--- a/src/file_handle_cache.erl
+++ b/src/file_handle_cache.erl
@@ -626,14 +626,16 @@ reopen([], Tree, RefHdls) ->
{ok, lists:reverse(RefHdls)};
reopen([{Ref, NewOrReopen, Handle = #handle { hdl = closed,
path = Path,
- mode = Mode,
+ mode = Mode0,
offset = Offset,
last_used_at = undefined }} |
RefNewOrReopenHdls] = ToOpen, Tree, RefHdls) ->
- case prim_file:open(Path, case NewOrReopen of
- new -> Mode;
- reopen -> [read | Mode]
- end) of
+ Mode = case NewOrReopen of
+ new -> Mode0;
+ reopen -> file_handle_cache_stats:update(reopen),
+ [read | Mode0]
+ end,
+ case prim_file:open(Path, Mode) of
{ok, Hdl} ->
Now = now(),
{{ok, _Offset}, Handle1} =
diff --git a/src/file_handle_cache_stats.erl b/src/file_handle_cache_stats.erl
index 5a8d7b29..b1fbb3f4 100644
--- a/src/file_handle_cache_stats.erl
+++ b/src/file_handle_cache_stats.erl
@@ -18,7 +18,7 @@
%% stats about read / write operations that go through the fhc.
--export([init/0, update/3, update/2, get/0]).
+-export([init/0, update/3, update/2, update/1, get/0]).
-define(TABLE, ?MODULE).
@@ -27,7 +27,9 @@ init() ->
[ets:insert(?TABLE, {{Op, Counter}, 0}) || Op <- [read, write],
Counter <- [count, bytes, time]],
[ets:insert(?TABLE, {{Op, Counter}, 0}) || Op <- [sync, seek],
- Counter <- [count, time]].
+ Counter <- [count, time]],
+ [ets:insert(?TABLE, {{Op, Counter}, 0}) || Op <- [reopen],
+ Counter <- [count]].
update(Op, Bytes, Thunk) ->
{Time, Res} = timer:tc(Thunk),
@@ -42,5 +44,9 @@ update(Op, Thunk) ->
ets:update_counter(?TABLE, {Op, time}, Time),
Res.
+update(Op) ->
+ ets:update_counter(?TABLE, {Op, count}, 1),
+ ok.
+
get() ->
lists:sort(ets:tab2list(?TABLE)).