summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDallas Marlow <dallas@vineapp.com>2015-04-06 12:33:23 -0400
committerDallas Marlow <dallas@vineapp.com>2015-04-06 12:33:23 -0400
commitd213071976cdfb0b785105d2793dcb48ad8d6e80 (patch)
tree458b760ba81b8085077edd04e050750b48e11bb9 /src
parentb71f39ffdb342c384894680bdefff3e59352c317 (diff)
downloadrabbitmq-server-git-d213071976cdfb0b785105d2793dcb48ad8d6e80.tar.gz
max gc interval backoff bounded by specifying a max interval of 4x the ideal interval
Diffstat (limited to 'src')
-rw-r--r--src/background_gc.erl3
-rw-r--r--src/rabbit_misc.erl13
2 files changed, 9 insertions, 7 deletions
diff --git a/src/background_gc.erl b/src/background_gc.erl
index d30fa89678..dc7ea9854d 100644
--- a/src/background_gc.erl
+++ b/src/background_gc.erl
@@ -26,6 +26,7 @@
-define(MAX_RATIO, 0.01).
-define(IDEAL_INTERVAL, 60000).
+-define(MAX_INTERVAL, 240000).
-record(state, {last_interval}).
@@ -70,7 +71,7 @@ terminate(_Reason, State) -> State.
interval_gc(State = #state{last_interval = LastInterval}) ->
{ok, Interval} = rabbit_misc:interval_operation(
{?MODULE, gc, []},
- ?MAX_RATIO, ?IDEAL_INTERVAL, LastInterval),
+ ?MAX_RATIO, ?MAX_INTERVAL, ?IDEAL_INTERVAL, LastInterval),
erlang:send_after(Interval, self(), run),
State#state{last_interval = Interval}.
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 5e9c7ceb40..72edc355a4 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -66,7 +66,7 @@
-export([json_encode/1, json_decode/1, json_to_term/1, term_to_json/1]).
-export([check_expiry/1]).
-export([base64url/1]).
--export([interval_operation/4]).
+-export([interval_operation/5]).
-export([ensure_timer/4, stop_timer/2, send_after/3, cancel_timer/1]).
-export([get_parent/0]).
-export([store_proc_name/1, store_proc_name/2]).
@@ -246,8 +246,8 @@
-spec(term_to_json/1 :: (any()) -> any()).
-spec(check_expiry/1 :: (integer()) -> rabbit_types:ok_or_error(any())).
-spec(base64url/1 :: (binary()) -> string()).
--spec(interval_operation/4 ::
- ({atom(), atom(), any()}, float(), non_neg_integer(), non_neg_integer())
+-spec(interval_operation/5 ::
+ ({atom(), atom(), any()}, float(), non_neg_integer(), non_neg_integer(), non_neg_integer())
-> {any(), non_neg_integer()}).
-spec(ensure_timer/4 :: (A, non_neg_integer(), non_neg_integer(), any()) -> A).
-spec(stop_timer/2 :: (A, non_neg_integer()) -> A).
@@ -1053,12 +1053,13 @@ base64url(In) ->
%% want it to take more than MaxRatio of IdealInterval. So if it takes
%% more then you want to run it less often. So we time how long it
%% takes to run, and then suggest how long you should wait before
-%% running it again. Times are in millis.
-interval_operation({M, F, A}, MaxRatio, IdealInterval, LastInterval) ->
+%% running it again with a user specified max interval. Times are in millis.
+interval_operation({M, F, A}, MaxRatio, MaxInterval, IdealInterval, LastInterval) ->
{Micros, Res} = timer:tc(M, F, A),
{Res, case {Micros > 1000 * (MaxRatio * IdealInterval),
Micros > 1000 * (MaxRatio * LastInterval)} of
- {true, true} -> round(LastInterval * 1.5);
+ {true, true} -> lists:min([MaxInterval,
+ round(LastInterval * 1.5)]);
{true, false} -> LastInterval;
{false, false} -> lists:max([IdealInterval,
round(LastInterval / 1.5)])