Skip to content

Commit 3cec2e0

Browse files
michaelklishinmergify[bot]
authored andcommitted
Reword a comment #10451 #9356
(cherry picked from commit dad9379)
1 parent a64f393 commit 3cec2e0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

deps/rabbitmq_management_agent/src/rabbit_mgmt_metrics_gc.erl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,15 @@ delete_samples(Table, Id, Intervals) ->
140140
ok.
141141

142142
index_delete(consumer_stats = Table, {channel = Type, ConsumerCount}, Id) ->
143-
%% In case of very large amount of consumers on a single channel,
144-
%% we use the more memoroy costly bulk operation `ets:match_delete` to reduce
145-
%% CPU load. For the more common case, few consumers per channel, we loop
146-
%% through the consumers and remove them one by one
143+
%% This uses two different deletion strategies depending on how many
144+
%% consumers a channel had. Most of the time there are many channels
145+
%% with a few (or even just one) consumers. For this common case, `ets:delete/2` is optimal
146+
%% since it avoids table scans.
147+
%%
148+
%% In the rather extreme scenario where only a handful of channels have a very large
149+
%% (e.g. tens of thousands) of consumers, `ets:match_delete/2` becomes a more efficient option.
150+
%%
151+
%% See rabbitmq-server/rabbitmq#10451, rabbitmq-server/rabbitmq#9356.
147152
case ConsumerCount > ?LARGE_CONSUMER_COUNT of
148153
true ->
149154
IndexTable = rabbit_mgmt_metrics_collector:index_table(Table, Type),

0 commit comments

Comments
 (0)