noahshaw11 commented on code in PR #3985:
URL: https://github.com/apache/couchdb/pull/3985#discussion_r876229365
##########
src/couch/src/couch_debug.erl:
##########
@@ -620,6 +635,90 @@ info_size(InfoKV) ->
{binary, BinInfos} -> lists:sum([S || {_, S, _} <- BinInfos]);
{_, V} -> V
end.
+resource_hoggers(MemoryInfo, InfoKey) ->
+ KeyFun = fun
+ ({_Pid, _Id, undefined}) -> undefined;
+ ({_Pid, _Id, DataMap}) -> maps:get(InfoKey, DataMap)
+ end,
+ resource_hoggers(MemoryInfo, InfoKey, KeyFun).
+
+resource_hoggers(MemoryInfo, InfoKey, KeyFun) ->
+ HoggersData = resource_hoggers_data(MemoryInfo, InfoKey, KeyFun),
+ TableSpec = [
+ {50, left, name},
+ {19, centre, InfoKey},
+ {id}
+ ],
+ print_table(HoggersData, TableSpec).
+
+resource_hoggers_data(MemoryInfo, InfoKey, KeyFun) when is_atom(InfoKey) ->
+ resource_hoggers_data(MemoryInfo, InfoKey, KeyFun, 20).
+
+resource_hoggers_data(MemoryInfo, InfoKey, KeyFun, N) when is_atom(InfoKey) ->
+ SortedTuples = resource_hoggers_data(MemoryInfo, InfoKey, KeyFun,
undefined),
Review Comment:
Making my own print function to better fit the data structure returned by
`resource_hoggers_data`:
```
([email protected])2> couch_debug:resource_hoggers(MI, memory).
id | memory
"couch_prometheus_server[<0.279.0>]" | 1945464
"config[<0.136.0>]" | 1115104
"erlang:apply/2[<0.1030.0>]" | 689368
"code_server[<0.51.0>]" | 426432
"couch_epi_data_gen_flags_config[<0.158.0>]" | 284688
"erlang:apply/2[<0.1029.0>]" | 264040
"couch_log_server[<0.167.0>]" | 263944
"couch_stats_aggregator[<0.183.0>]" | 196992
"couch_epi_functions_gen_chttpd_handlers[<0.145.0>]" | 196912
"couch_epi_functions_gen_couch_db[<0.149.0>]" | 176216
"erl_prim_loader[<0.10.0>]" | 176208
"couch_proc_manager[<0.337.0>]" | 142872
"couch_secondary_services[<0.335.0>]" | 110240
"couch_epi_data_gen_dreyfus_black_list[<0.153.0>]" | 109280
"config_event[<0.137.0>]" | 69808
"standard_error[<0.68.0>]" | 42304
"couch_epi_functions_gen_global_changes[<0.160.0>]" | 42264
"couch_epi_functions_gen_feature_flags[<0.156.0>]" | 42264
"couch_epi_functions_gen_couch_index[<0.151.0>]" | 42264
"couch_epi_functions_gen_chttpd[<0.147.0>]" | 42264
ok
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]