@@ -44,8 +44,8 @@ handle_cast({event, #event{type = connection_closed, props = Props}},
44
44
handle_cast ({event , # event {type = channel_closed , props = Props }},
45
45
State = # state {basic_i = BIntervals }) ->
46
46
Pid = pget (pid , Props ),
47
- CMCount = pget (consumer_count , Props ),
48
- remove_channel (Pid , CMCount , BIntervals ),
47
+ ConsumerCount = pget (consumer_count , Props ),
48
+ remove_channel (Pid , ConsumerCount , BIntervals ),
49
49
{noreply , State };
50
50
handle_cast ({event , # event {type = consumer_deleted , props = Props }}, State ) ->
51
51
remove_consumer (Props ),
@@ -85,13 +85,13 @@ remove_connection(Id, BIntervals) ->
85
85
delete_samples (connection_stats_coarse_conn_stats , Id , BIntervals ),
86
86
ok .
87
87
88
- remove_channel (Id , CMCount , BIntervals ) ->
88
+ remove_channel (Id , ConsumerCount , BIntervals ) ->
89
89
ets :delete (channel_created_stats , Id ),
90
90
ets :delete (channel_stats , Id ),
91
91
delete_samples (channel_process_stats , Id , BIntervals ),
92
92
delete_samples (channel_stats_fine_stats , Id , BIntervals ),
93
93
delete_samples (channel_stats_deliver_stats , Id , BIntervals ),
94
- index_delete (consumer_stats , {channel , CMCount }, Id ),
94
+ index_delete (consumer_stats , {channel , ConsumerCount }, Id ),
95
95
index_delete (channel_exchange_stats_fine_stats , channel , Id ),
96
96
index_delete (channel_queue_stats_deliver_stats , channel , Id ),
97
97
ok .
@@ -140,8 +140,12 @@ delete_samples(Table, Id, Intervals) ->
140
140
[ets :delete (Table , {Id , I }) || I <- Intervals ],
141
141
ok .
142
142
143
- index_delete (consumer_stats = Table , {channel = Type , Count }, Id ) ->
144
- case Count > ? LARGE_CONSUMER_COUNT of
143
+ 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
148
+ case ConsumerCount > ? LARGE_CONSUMER_COUNT of
145
149
true ->
146
150
IndexTable = rabbit_mgmt_metrics_collector :index_table (Table , Type ),
147
151
MatchPattern = {'_' , Id , '_' },
0 commit comments