summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2013-01-07 23:05:17 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2013-01-07 23:05:17 +0000
commit547d0e785e915ee18ca379a610a66097d8f10010 (patch)
tree1088ac4ce94630fbccc6426ff176a4cfd94b0595
parent10aa5f6c24d0d0cd7a892367141768d4e05b1084 (diff)
downloadrabbitmq-server-547d0e785e915ee18ca379a610a66097d8f10010.tar.gz
optimise vq:reduce_memory_use/4 invocations
by suppressing the call, and thus the closure creations, when target_ram_count == infinity
-rw-r--r--src/rabbit_variable_queue.erl26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl
index 37ca6de0..6ac7feaa 100644
--- a/src/rabbit_variable_queue.erl
+++ b/src/rabbit_variable_queue.erl
@@ -783,19 +783,24 @@ ram_duration(State = #vqstate {
ram_msg_count_prev = RamMsgCount,
ram_ack_count_prev = RamAckCount }}.
-needs_timeout(State = #vqstate { index_state = IndexState }) ->
+needs_timeout(State = #vqstate { index_state = IndexState,
+ target_ram_count = TargetRamCount }) ->
case must_sync_index(State) of
true -> timed;
false ->
case rabbit_queue_index:needs_sync(IndexState) of
true -> idle;
- false -> case reduce_memory_use(
- fun (_Quota, State1) -> {0, State1} end,
- fun (_Quota, State1) -> State1 end,
- fun (_Quota, State1) -> {0, State1} end,
- State) of
- {true, _State} -> idle;
- {false, _State} -> false
+ false -> case TargetRamCount of
+ infinity -> false;
+ _ -> case
+ reduce_memory_use(
+ fun (_Quota, State1) -> {0, State1} end,
+ fun (_Quota, State1) -> State1 end,
+ fun (_Quota, State1) -> {0, State1} end,
+ State) of
+ {true, _State} -> idle;
+ {false, _State} -> false
+ end
end
end
end.
@@ -1495,9 +1500,6 @@ delta_fold( Fun, {cont, Acc}, DeltaSeqId, DeltaSeqIdEnd,
%% one segment's worth of messages in q3 - and thus would risk
%% perpetually reporting the need for a conversion when no such
%% conversion is needed. That in turn could cause an infinite loop.
-reduce_memory_use(_AlphaBetaFun, _BetaDeltaFun, _AckFun,
- State = #vqstate {target_ram_count = infinity}) ->
- {false, State};
reduce_memory_use(AlphaBetaFun, BetaDeltaFun, AckFun,
State = #vqstate {
ram_ack_index = RamAckIndex,
@@ -1552,6 +1554,8 @@ limit_ram_acks(Quota, State = #vqstate { pending_ack = PA,
ram_ack_index = RAI1 })
end.
+reduce_memory_use(State = #vqstate { target_ram_count = infinity }) ->
+ State;
reduce_memory_use(State) ->
{_, State1} = reduce_memory_use(fun push_alphas_to_betas/2,
fun push_betas_to_deltas/2,