Skip to content

Commit

Permalink
Remove file_handle_cache_stats module
Browse files Browse the repository at this point in the history
The stats were not removed from management agent, instead
they are hardcoded to zero in the agent itself.
  • Loading branch information
lhoguin committed Jun 18, 2024
1 parent 64b639e commit b720a28
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 92 deletions.
2 changes: 0 additions & 2 deletions deps/rabbit/src/rabbit_classic_queue_index_v2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ flush_buffer(State0 = #qi { write_buffer = WriteBuffer0,
{Fd, FoldState} = get_fd_for_segment(Segment, FoldState1),
LocBytes = flush_buffer_consolidate(lists:sort(LocBytes0), 1),
ok = file:pwrite(Fd, LocBytes),
file_handle_cache_stats:update(queue_index_write),
FoldState
end, State0, Writes),
%% Update the cache. If we are flushing the entire write buffer,
Expand Down Expand Up @@ -961,7 +960,6 @@ read_from_disk(SeqIdsToRead0, State0 = #qi{ write_buffer = WriteBuffer }, Acc0)
ReadSize = (LastSeqId - FirstSeqId + 1) * ?ENTRY_SIZE,
case get_fd(FirstSeqId, State0) of
{Fd, OffsetForSeqId, State} ->
file_handle_cache_stats:update(queue_index_read),
%% When reading further than the end of a partial file,
%% file:pread/3 will return what it could read.
case file:pread(Fd, OffsetForSeqId, ReadSize) of
Expand Down
8 changes: 2 additions & 6 deletions deps/rabbit/src/rabbit_mnesia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,8 @@ execute_mnesia_transaction(TxFun) ->
Res = mnesia:sync_transaction(TxFun),
DiskLogAfter = mnesia_dumper:get_log_writes(),
case DiskLogAfter == DiskLogBefore of
true -> file_handle_cache_stats:update(
mnesia_ram_tx),
Res;
false -> file_handle_cache_stats:update(
mnesia_disk_tx),
{sync, Res}
true -> Res;
false -> {sync, Res}
end;
true -> mnesia:sync_transaction(TxFun)
end
Expand Down
3 changes: 0 additions & 3 deletions deps/rabbit/src/rabbit_msg_store.erl
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ write(MsgRef, MsgId, Msg, CState) -> client_write(MsgRef, MsgId, Msg, noflow, CS

read(MsgId, CState = #client_msstate { index_ets = IndexEts,
cur_file_cache_ets = CurFileCacheEts }) ->
file_handle_cache_stats:update(msg_store_read),
%% Check the cur file cache
case ets:lookup(CurFileCacheEts, MsgId) of
[] ->
Expand All @@ -480,7 +479,6 @@ read(MsgId, CState = #client_msstate { index_ets = IndexEts,
-> {#{rabbit_types:msg_id() => msg()}, client_msstate()}.

read_many(MsgIds, CState) ->
file_handle_cache_stats:inc(msg_store_read, length(MsgIds)),
%% We receive MsgIds in rouhgly the younger->older order so
%% we can look for messages in the cache directly.
read_many_cache(MsgIds, CState, #{}).
Expand Down Expand Up @@ -592,7 +590,6 @@ client_write(MsgRef, MsgId, Msg, Flow,
CState = #client_msstate { flying_ets = FlyingEts,
cur_file_cache_ets = CurFileCacheEts,
client_ref = CRef }) ->
file_handle_cache_stats:update(msg_store_write),
%% We are guaranteed that the insert will succeed.
%% This is true even for queue crashes because CRef will change.
true = ets:insert_new(FlyingEts, {{CRef, MsgRef}, ?FLYING_WRITE}),
Expand Down
3 changes: 0 additions & 3 deletions deps/rabbit/src/rabbit_queue_index.erl
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,6 @@ append_journal_to_segment(#segment { journal_entries = JEntries,
case array:sparse_size(JEntries) of
0 -> Segment;
_ ->
file_handle_cache_stats:update(queue_index_write),

{ok, Hdl} = file_handle_cache:open_with_absolute_path(
Path, ?WRITE_MODE,
[{write_buffer, infinity}]),
Expand Down Expand Up @@ -1172,7 +1170,6 @@ load_segment(KeepAcked, #segment { path = Path }) ->
case rabbit_file:is_file(Path) of
false -> Empty;
true -> Size = rabbit_file:file_size(Path),
file_handle_cache_stats:update(queue_index_read),
{ok, Hdl} = file_handle_cache:open_with_absolute_path(
Path, ?READ_MODE, []),
{ok, 0} = file_handle_cache:position(Hdl, bof),
Expand Down
3 changes: 0 additions & 3 deletions deps/rabbit_common/app.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def all_beam_files(name = "all_beam_files"):
"src/delegate.erl",
"src/delegate_sup.erl",
"src/file_handle_cache.erl",
"src/file_handle_cache_stats.erl",
"src/mirrored_supervisor_locks.erl",
"src/mnesia_sync.erl",
"src/pmon.erl",
Expand Down Expand Up @@ -124,7 +123,6 @@ def all_test_beam_files(name = "all_test_beam_files"):
"src/delegate.erl",
"src/delegate_sup.erl",
"src/file_handle_cache.erl",
"src/file_handle_cache_stats.erl",
"src/mirrored_supervisor_locks.erl",
"src/mnesia_sync.erl",
"src/pmon.erl",
Expand Down Expand Up @@ -211,7 +209,6 @@ def all_srcs(name = "all_srcs"):
"src/delegate.erl",
"src/delegate_sup.erl",
"src/file_handle_cache.erl",
"src/file_handle_cache_stats.erl",
"src/gen_server2.erl",
"src/mirrored_supervisor_locks.erl",
"src/mnesia_sync.erl",
Expand Down
15 changes: 5 additions & 10 deletions deps/rabbit_common/src/file_handle_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -660,19 +660,16 @@ get_client_state(Pid) ->
%%----------------------------------------------------------------------------

prim_file_read(Hdl, Size) ->
file_handle_cache_stats:update(
io_read, Size, fun() -> prim_file:read(Hdl, Size) end).
prim_file:read(Hdl, Size).

prim_file_write(Hdl, Bytes) ->
file_handle_cache_stats:update(
io_write, iolist_size(Bytes), fun() -> prim_file:write(Hdl, Bytes) end).
prim_file:write(Hdl, Bytes).

prim_file_sync(Hdl) ->
file_handle_cache_stats:update(io_sync, fun() -> prim_file:sync(Hdl) end).
prim_file:sync(Hdl).

prim_file_position(Hdl, NewOffset) ->
file_handle_cache_stats:update(
io_seek, fun() -> prim_file:position(Hdl, NewOffset) end).
prim_file:position(Hdl, NewOffset).

is_reader(Mode) -> lists:member(read, Mode).

Expand Down Expand Up @@ -766,8 +763,7 @@ reopen([{Ref, NewOrReopen, Handle = #handle { hdl = closed,
RefNewOrReopenHdls] = ToOpen, Tree, RefHdls) ->
Mode = case NewOrReopen of
new -> Mode0;
reopen -> file_handle_cache_stats:update(io_reopen),
[read | Mode0]
reopen -> [read | Mode0]
end,
case prim_file:open(Path, Mode) of
{ok, Hdl} ->
Expand Down Expand Up @@ -1103,7 +1099,6 @@ used(#fhc_state{open_count = C1,
%%----------------------------------------------------------------------------

init([AlarmSet, AlarmClear]) ->
_ = file_handle_cache_stats:init(),
Limit = case application:get_env(file_handles_high_watermark) of
{ok, Watermark} when (is_integer(Watermark) andalso
Watermark > 0) ->
Expand Down
63 changes: 0 additions & 63 deletions deps/rabbit_common/src/file_handle_cache_stats.erl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,23 @@ update_state(State0) ->
FHC = get_fhc_stats(),
State0#state{fhc_stats = FHC}.

%% @todo All these stats are zeroes. Remove eventually.
get_fhc_stats() ->
dict:to_list(dict:merge(fun(_, V1, V2) -> V1 + V2 end,
dict:from_list(file_handle_cache_stats:get()),
dict:from_list(zero_fhc_stats()),
dict:from_list(get_ra_io_metrics()))).

zero_fhc_stats() ->
[{{Op, Counter}, 0} || Op <- [io_read, io_write],
Counter <- [count, bytes, time]]
++
[{{Op, Counter}, 0} || Op <- [io_sync, io_seek],
Counter <- [count, time]]
++
[{{Op, Counter}, 0} || Op <- [io_reopen, mnesia_ram_tx, mnesia_disk_tx,
msg_store_read, msg_store_write,
queue_index_write, queue_index_read],
Counter <- [count]].

get_ra_io_metrics() ->
lists:sort(ets:tab2list(ra_io_metrics)).
1 change: 0 additions & 1 deletion moduleindex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ rabbit_common:
- delegate
- delegate_sup
- file_handle_cache
- file_handle_cache_stats
- gen_server2
- mirrored_supervisor_locks
- mnesia_sync
Expand Down

0 comments on commit b720a28

Please sign in to comment.