aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-08-04 10:14:44 +0200
committerAnders Svensson <[email protected]>2015-08-05 10:16:32 +0200
commit9c0f2f2ce3ed040b3963d5b00cad0276c276d590 (patch)
tree62376f660ce74d0b156b26724c07a879ce868e23 /lib/diameter/src
parent84004d4f99271e8324f7d1e3fb8a3cd68109d456 (diff)
downloadotp-9c0f2f2ce3ed040b3963d5b00cad0276c276d590.tar.gz
otp-9c0f2f2ce3ed040b3963d5b00cad0276c276d590.tar.bz2
otp-9c0f2f2ce3ed040b3963d5b00cad0276c276d590.zip
Remove use of monotonic time in pre-18 code
This has been seen to be a bottleneck at high load: each undef results in a loop out to the code server. Originally implemented as suggested in the erts user's guide, in commits e6d19a18 and d4386254.
Diffstat (limited to 'lib/diameter/src')
-rw-r--r--lib/diameter/src/base/diameter_lib.erl40
-rw-r--r--lib/diameter/src/base/diameter_watchdog.erl1
2 files changed, 6 insertions, 35 deletions
diff --git a/lib/diameter/src/base/diameter_lib.erl b/lib/diameter/src/base/diameter_lib.erl
index 3f327f3653..6a94e32b0e 100644
--- a/lib/diameter/src/base/diameter_lib.erl
+++ b/lib/diameter/src/base/diameter_lib.erl
@@ -102,8 +102,7 @@ fmt(T) ->
%% ---------------------------------------------------------------------------
-type timestamp() :: {non_neg_integer(), 0..999999, 0..999999}.
--type now() :: integer() %% monotonic time
- | timestamp().
+-type now() :: timestamp().
-spec now()
-> now().
@@ -112,11 +111,7 @@ fmt(T) ->
%% otherwise.
now() ->
- try
- erlang:monotonic_time()
- catch
- error: undef -> erlang:now()
- end.
+ erlang:now().
%% ---------------------------------------------------------------------------
%% # timestamp/1
@@ -126,15 +121,7 @@ now() ->
-> timestamp().
timestamp({_,_,_} = T) -> %% erlang:now()
- T;
-
-timestamp(MonoT) -> %% monotonic time
- MicroSecs = monotonic_to_microseconds(MonoT + erlang:time_offset()),
- Secs = MicroSecs div 1000000,
- {Secs div 1000000, Secs rem 1000000, MicroSecs rem 1000000}.
-
-monotonic_to_microseconds(MonoT) ->
- erlang:convert_time_unit(MonoT, native, micro_seconds).
+ T.
%% ---------------------------------------------------------------------------
%% # now_diff/1
@@ -162,10 +149,7 @@ now_diff(Time) ->
when MicroSecs :: non_neg_integer().
micro_diff({_,_,_} = T0) ->
- timer:now_diff(erlang:now(), T0);
-
-micro_diff(T0) -> %% monotonic time
- monotonic_to_microseconds(erlang:monotonic_time() - T0).
+ timer:now_diff(erlang:now(), T0).
%% ---------------------------------------------------------------------------
%% # micro_diff/2
@@ -175,12 +159,8 @@ micro_diff(T0) -> %% monotonic time
-> MicroSecs
when MicroSecs :: non_neg_integer().
-micro_diff(T1, T0)
- when is_integer(T1), is_integer(T0) -> %% monotonic time
- monotonic_to_microseconds(T1 - T0);
-
micro_diff(T1, T0) -> %% at least one erlang:now()
- timer:now_diff(timestamp(T1), timestamp(T0)).
+ timer:now_diff(T1, T0).
%% ---------------------------------------------------------------------------
%% # time/1
@@ -219,15 +199,7 @@ time(Micro) -> %% elapsed time
seed() ->
T = now(),
- {timestamp(T), seed(T)}.
-
-%% seed/1
-
-seed({_,_,_} = T) ->
- T;
-
-seed(T) -> %% monotonic time
- {erlang:phash2(node()), T, erlang:unique_integer()}.
+ {T, T}.
%% ---------------------------------------------------------------------------
%% # eval/1
diff --git a/lib/diameter/src/base/diameter_watchdog.erl b/lib/diameter/src/base/diameter_watchdog.erl
index 0607c72818..66781d7b06 100644
--- a/lib/diameter/src/base/diameter_watchdog.erl
+++ b/lib/diameter/src/base/diameter_watchdog.erl
@@ -66,7 +66,6 @@
parent = self() :: pid(), %% service process
transport :: pid() | undefined, %% peer_fsm process
tref :: reference() %% reference for current watchdog timer
- | integer() %% monotonic time
| tuple() %% now()
| undefined,
dictionary :: module(), %% common dictionary