noahshaw11 commented on code in PR #3985:
URL: https://github.com/apache/couchdb/pull/3985#discussion_r876192654
##########
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:
This is my result with the extra guard:
```
([email protected])2> couch_debug:resource_hoggers(MI, memory).
|name | memory |id
** exception error: no function clause matching
couch_debug:'-print_table/2-fun-0-'({1945464})
(src/couch_debug.erl, line 837)
in function lists:foreach/2 (lists.erl, line 1342)
in call from couch_debug:print_table/2 (src/couch_debug.erl, line 836)
```
--
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]