You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/05/18 17:45:25 UTC

[GitHub] [couchdb] noahshaw11 commented on a diff in pull request #3985: Implement resource_hoggers

noahshaw11 commented on code in PR #3985:
URL: https://github.com/apache/couchdb/pull/3985#discussion_r876176661


##########
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:
   The infinite loop is here:
   ```
   resource_hoggers(MemoryInfo, InfoKey, KeyFun) ->
       HoggersData = resource_hoggers_data(MemoryInfo, InfoKey, KeyFun),
       TableSpec = [
           {50, left, name},
           {19, centre, InfoKey},
           {id}
       ],
       print_table(HoggersData, TableSpec).
   ```



-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org