Skip to content

Commit e31d260

Browse files
Reword a comment #10451 #9356
1 parent f5e42cd commit e31d260

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
@@ -141,10 +141,15 @@ delete_samples(Table, Id, Intervals) ->
141141
ok.
142142

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

0 commit comments

Comments
 (0)