Skip to content

Commit

Permalink
feat: support show ets size and go to specific pid
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwencool committed Oct 21, 2024
1 parent acc493f commit ea25657
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/observer_cli.erl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ manager(StorePid, RenderPid, Opts, LastSchWallFlag) ->
NewPages = observer_cli_lib:update_page_pos(StorePid, NewPage, Pages),
clean(Resource),
start(Opts#view_opts{home = Home#home{cur_page = NewPage, pages = NewPages}});
{go_to_pid, Pid} ->
clean(Resource),
observer_cli_process:start(home, Pid, Opts);
_ ->
manager(StorePid, RenderPid, Opts, LastSchWallFlag)
end.
Expand Down Expand Up @@ -289,6 +292,7 @@ render_memory_process_line(MemSum, PortParallelism, Interval) ->
AtomMem = proplists:get_value(atom_used, Mem),
BinMem = proplists:get_value(binary, Mem),
EtsMem = proplists:get_value(ets, Mem),
EtsLen = erlang:length(ets:all()),
{
BytesIn,
BytesOut,
Expand Down Expand Up @@ -349,7 +353,7 @@ render_memory_process_line(MemSum, PortParallelism, Interval) ->
?W("Gc Count", 20),
?W(GcCount, 24),
?NEW_LINE,
?W("Ets", 10),
?W("Ets/" ++ erlang:integer_to_list(EtsLen), 10),
?W({byte, EtsMem}, 12),
?W(EtsMemPercent, 6),
?W(LogKey, 25),
Expand Down
34 changes: 18 additions & 16 deletions src/observer_cli_help.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,24 @@ render_help() ->
"| \e[48;2;80;80;80m1.3\e[0m observer_start:start(Node, Cookie).\n",

"|\e[44m2. HOME(H) Commands\e[49m \n",
"| \e[48;2;80;80;80m` \e[0m enable/disable schedule usage.\n",
"| \e[48;2;80;80;80mPageDown \e[0m pd or F(forward).\n",
"| \e[48;2;80;80;80mPageUp \e[0m pu or B(back).\n",
"| \e[48;2;80;80;80mr \e[0m switch mode to reduction(proc_count).\n",
"| \e[48;2;80;80;80mrr \e[0m switch mode to reduction(proc_window).\n",
"| \e[48;2;80;80;80mm \e[0m switch mode to memory(proc_count).\n",
"| \e[48;2;80;80;80mmm \e[0m switch mode to memory(proc_window).\n",
"| \e[48;2;80;80;80mb \e[0m switch mode to bin memory(proc_count).\n",
"| \e[48;2;80;80;80mbb \e[0m switch mode to bin memory(proc_window).\n",
"| \e[48;2;80;80;80mmq \e[0m switch mode to message queue len(proc_count).\n",
"| \e[48;2;80;80;80mmmq \e[0m switch mode to message queue len(proc_window).\n",
"| \e[48;2;80;80;80mt \e[0m switch mode to total heap size(proc_count).\n",
"| \e[48;2;80;80;80mtt \e[0m switch mode to total heap size(proc_window).\n",
"| \e[48;2;80;80;80m3000 \e[0m set interval time to 3000ms, the integer must >= 1500.\n",
"| \e[48;2;80;80;80m13 \e[0m choose the 13th process(green line), the integer must in top list.\n",
"| \e[48;2;80;80;80mp \e[0m pause/unpause the view.\n",
"| \e[48;2;80;80;80m` \e[0m enable/disable schedule usage.\n",
"| \e[48;2;80;80;80mPageDown \e[0m pd or F(forward).\n",
"| \e[48;2;80;80;80mPageUp \e[0m pu or B(back).\n",
"| \e[48;2;80;80;80mr \e[0m switch mode to reduction(proc_count).\n",
"| \e[48;2;80;80;80mrr \e[0m switch mode to reduction(proc_window).\n",
"| \e[48;2;80;80;80mm \e[0m switch mode to memory(proc_count).\n",
"| \e[48;2;80;80;80mmm \e[0m switch mode to memory(proc_window).\n",
"| \e[48;2;80;80;80mb \e[0m switch mode to bin memory(proc_count).\n",
"| \e[48;2;80;80;80mbb \e[0m switch mode to bin memory(proc_window).\n",
"| \e[48;2;80;80;80mmq \e[0m switch mode to message queue len(proc_count).\n",
"| \e[48;2;80;80;80mmmq \e[0m switch mode to message queue len(proc_window).\n",
"| \e[48;2;80;80;80mt \e[0m switch mode to total heap size(proc_count).\n",
"| \e[48;2;80;80;80mtt \e[0m switch mode to total heap size(proc_window).\n",
"| \e[48;2;80;80;80m3000 \e[0m set interval time to 3000ms, the integer must >= 1500.\n",
"| \e[48;2;80;80;80m13 \e[0m choose the 13th process(green line), the integer must in top list.\n",
"| \e[48;2;80;80;80m<0.43.0> \e[0m choose the <0.43.0> process, the pid does not need to be in the top list.\n",
"| \e[48;2;80;80;80m<43 or >43 \e[0m choose the <0.43.0> process, the pid does not need to be in the top list.\n",
"| \e[48;2;80;80;80mp \e[0m pause/unpause the view.\n",

"|\e[44m5. Reference\e[49m \n",
"|More information about recon:proc_count/2 and recon:proc_window/3 \n",
Expand Down
15 changes: 15 additions & 0 deletions src/observer_cli_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,28 @@ parse_cmd(ViewOpts, Module, Args) ->
hide;
"`\n" ->
scheduler_usage;
[$< | PidStr] ->
to_pid(PidStr);
[$> | PidStr] ->
to_pid(PidStr);
%% {error, estale}|{error, terminated}
{error, _Reason} ->
quit;
Number ->
parse_integer(Number)
end.

-spec to_pid(string()) -> {go_to_pid, pid()} | quit.
to_pid(Str) ->
case string:tokens(Str, ".<>\n") of
[X, Y, Z] ->
{go_to_pid, list_to_pid("<" ++ X ++ "." ++ Y ++ "." ++ Z ++ ">")};
[Y] ->
{go_to_pid, list_to_pid("<0." ++ Y ++ ".0>")};
_ ->
quit
end.

-spec next_redraw(reference(), pos_integer()) -> reference().
next_redraw(LastTimeRef, Interval) ->
LastTimeRef =/= ?INIT_TIME_REF andalso erlang:cancel_timer(LastTimeRef),
Expand Down

0 comments on commit ea25657

Please sign in to comment.