aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-07-22 00:43:35 +0200
committerAnders Svensson <[email protected]>2015-08-07 09:02:05 +0200
commitfaf86cb3cee3b241faf82b4dc347b0d2b0c58201 (patch)
treea87e27935bb6d45885f86204a6880ea04c8649d4 /lib
parent9b09b6473e85c1753e9a915d44b7df679a79cd8f (diff)
downloadotp-faf86cb3cee3b241faf82b4dc347b0d2b0c58201.tar.gz
otp-faf86cb3cee3b241faf82b4dc347b0d2b0c58201.tar.bz2
otp-faf86cb3cee3b241faf82b4dc347b0d2b0c58201.zip
Make ets diameter_stats a set
There's no need for it to be ordered, and the ordering has been seen to have an unexpectedly negative impact on performance in some cases. Order when retrieving statistics instead, so as not to change the presentation in diameter:service_info/2.
Diffstat (limited to 'lib')
-rw-r--r--lib/diameter/src/base/diameter_stats.erl16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/diameter/src/base/diameter_stats.erl b/lib/diameter/src/base/diameter_stats.erl
index d2c760317a..79a5c7b947 100644
--- a/lib/diameter/src/base/diameter_stats.erl
+++ b/lib/diameter/src/base/diameter_stats.erl
@@ -142,9 +142,14 @@ read(Refs, B) ->
L.
to_refdict(L) ->
- lists:foldl(fun({{C,R}, N}, D) -> orddict:append(R, {C,N}, D) end,
- orddict:new(),
- L).
+ lists:foldl(fun append/2, orddict:new(), L).
+
+%% Order both references and counters in the returned list.
+append({{Ctr, Ref}, N}, Dict) ->
+ orddict:update(Ref,
+ fun(D) -> orddict:store(Ctr, N, D) end,
+ [{Ctr, N}],
+ Dict).
%% ---------------------------------------------------------------------------
%% # sum(Refs)
@@ -220,10 +225,7 @@ uptime() ->
%% ----------------------------------------------------------
init([]) ->
- ets:new(?TABLE, [named_table,
- ordered_set,
- public,
- {write_concurrency, true}]),
+ ets:new(?TABLE, [named_table, set, public, {write_concurrency, true}]),
{ok, #state{}}.
%% ----------------------------------------------------------