From ea2f229a0335aaaa1a5fcfb8eec0c7881cfdf7bb Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Tue, 5 Aug 2014 17:22:15 +0200 Subject: 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. --- lib/diameter/src/base/diameter_service.erl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/diameter/src/base/diameter_service.erl') 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. -- cgit v1.2.3