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/26 14:05:58 UTC

[GitHub] [couchdb] iilyak commented on a diff in pull request #4033: Implement view_report function

iilyak commented on code in PR #4033:
URL: https://github.com/apache/couchdb/pull/4033#discussion_r882707436


##########
src/couch/src/couch_debug.erl:
##########
@@ -794,6 +795,68 @@ id("couch_file:init" ++ _, Pid, _Props) ->
 id(_IdStr, _Pid, _Props) ->
     "".
 
+first_call(Pid) ->
+    IC =
+        case process_info(Pid, initial_call) of
+            {initial_call, IC0} -> IC0;
+            undefined -> undefined
+        end,
+    Dict =
+        case process_info(Pid, dictionary) of
+            {dictionary, Dict0} -> Dict0;
+            undefined -> []
+        end,
+    MaybeCall = proplists:get_value('$initial_call', Dict, IC),
+    proplists:get_value(initial_call, Dict, MaybeCall).
+
+find_by_first_call(Module, Function) ->
+    FilterPids = fun(Pid) ->
+        case first_call(Pid) of
+            {Module, Function, _} -> true;
+            _ -> false
+        end
+    end,
+    lists:filter(FilterPids, processes()).
+
+view_report() ->

Review Comment:
   I don't think this is the best place for this function. It knows too much about index internals. Let's move it into https://github.com/apache/couchdb/blob/3.x/src/couch_mrview/src/couch_mrview_debug.erl
   
   Also I think the API should be:
   
   - `processes() -> [pid()]`
   - `processes_info(Pid) -> {pid(), id(), map()}.` - not sure about id()
   - `report(Pid) -> prints report` - you would call the function above to get all info and format it nicelly
   
   
   



-- 
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