25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Take into consideration internal queue length when sorting processes queues

This commit is contained in:
Evgeniy Khramtsov 2011-05-05 16:08:28 +10:00
parent 84c1cf8033
commit dfbfd90f8c

View File

@ -156,10 +156,10 @@ queue(N) ->
dump(N, lists:reverse(lists:ukeysort(1, all_pids(queue)))). dump(N, lists:reverse(lists:ukeysort(1, all_pids(queue)))).
memory(N) -> memory(N) ->
dump(N, lists:reverse(lists:ukeysort(2, all_pids(memory)))). dump(N, lists:reverse(lists:ukeysort(3, all_pids(memory)))).
reds(N) -> reds(N) ->
dump(N, lists:reverse(lists:ukeysort(3, all_pids(reductions)))). dump(N, lists:reverse(lists:ukeysort(4, all_pids(reductions)))).
trace(Pid) -> trace(Pid) ->
erlang:trace(Pid, true, [send, 'receive']), erlang:trace(Pid, true, [send, 'receive']),
@ -299,10 +299,17 @@ all_pids(Type) ->
registered_name]) of registered_name]) of
[{_, Len}, {_, Memory}, {_, Reds}, [{_, Len}, {_, Memory}, {_, Reds},
{_, Dict}, {_, CurFun}, {_, RegName}] -> {_, Dict}, {_, CurFun}, {_, RegName}] ->
if Type == queue andalso Len == 0 -> IntQLen = case lists:keysearch('$internal_queue_len', 1, Dict) of
{value, {_, N}} ->
N;
_ ->
0
end,
if Type == queue andalso Len == 0 andalso IntQLen == 0 ->
Acc; Acc;
true -> true ->
[{Len, Memory, Reds, Dict, CurFun, P, RegName}|Acc] MaxLen = lists:max([Len, IntQLen]),
[{MaxLen, Len, Memory, Reds, Dict, CurFun, P, RegName}|Acc]
end; end;
_ -> _ ->
Acc Acc
@ -311,7 +318,7 @@ all_pids(Type) ->
dump(N, Rs) -> dump(N, Rs) ->
lists:foreach( lists:foreach(
fun({MsgQLen, Memory, Reds, Dict, CurFun, Pid, RegName}) -> fun({_, MsgQLen, Memory, Reds, Dict, CurFun, Pid, RegName}) ->
PidStr = pid_to_list(Pid), PidStr = pid_to_list(Pid),
[_, Maj, Min] = string:tokens( [_, Maj, Min] = string:tokens(
string:substr( string:substr(