aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_service.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2014-08-05 17:22:15 +0200
committerAnders Svensson <[email protected]>2014-08-05 18:00:59 +0200
commitea2f229a0335aaaa1a5fcfb8eec0c7881cfdf7bb (patch)
treec73503e0644c098ebd297b6dfc89227d90aa0ad2 /lib/diameter/src/base/diameter_service.erl
parent66833b6dc19dd7fd8a19862e7815c6c3c1b4f230 (diff)
downloadotp-ea2f229a0335aaaa1a5fcfb8eec0c7881cfdf7bb.tar.gz
otp-ea2f229a0335aaaa1a5fcfb8eec0c7881cfdf7bb.tar.bz2
otp-ea2f229a0335aaaa1a5fcfb8eec0c7881cfdf7bb.zip
Map binary process info to a reference/byte count
That is, instead of including the list in a diameter:service_info/2 info tuple, only include the number of references and the number of bytes referenced. The list itself can be quite large and typically isn't that interesting, at least not to a diameter user.
Diffstat (limited to 'lib/diameter/src/base/diameter_service.erl')
-rw-r--r--lib/diameter/src/base/diameter_service.erl17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl
index 44c2b707b7..ab56ca9cef 100644
--- a/lib/diameter/src/base/diameter_service.erl
+++ b/lib/diameter/src/base/diameter_service.erl
@@ -1786,8 +1786,23 @@ info_pid(Pid) ->
[{Pid, lists:map(fun({K,V}) -> {K, map_info(K,V)} end, L)}]
end.
+%% The binary list consists of 3-tuples {Ptr, Size, Count}, where Ptr
+%% is a C pointer value, Size is the size of a referenced binary in
+%% bytes, and Count is a global reference count. The same Ptr can
+%% occur multiple times, once for each reference on the process heap.
+%% In this case, the corresponding tuples will have Size in common but
+%% Count may differ just because no global lock is taken when the
+%% value is retrieved.
+%%
+%% The list can be quite large, and we aren't often interested in the
+%% pointers or counts, so whittle this down to the number of binaries
+%% referenced and their total byte count.
map_info(binary, L) ->
- lists:reverse(lists:keysort(2, L));
+ SzD = lists:foldl(fun({P,S,_}, D) -> dict:store(P,S,D) end,
+ dict:new(),
+ L),
+ {dict:size(SzD), dict:fold(fun(_,S,N) -> S + N end, 0, SzD)};
+
map_info(_, T) ->
T.