diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-12-05 18:57:19 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-12-05 18:57:19 +0000 |
commit | 4551f44b18a848e1dc3d543e5ccc3ca1c9dc2932 (patch) | |
tree | 2d55c148b8ebedf7fc888f813e2aefb737c425ac | |
parent | 1646f9716e4daa5f8f679ed04d8c86d48fe6ec75 (diff) | |
download | rabbitmq-server-4551f44b18a848e1dc3d543e5ccc3ca1c9dc2932.tar.gz |
cosmetic
-rw-r--r-- | src/rabbit_variable_queue.erl | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index 7c676164..ce80bc92 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -1471,31 +1471,22 @@ reduce_memory_use(AlphaBetaFun, BetaGammaFun, BetaDeltaFun, AckFun, {Reduce, State1} = case chunk_size(RamMsgCount + gb_trees:size(RamAckIndex), TargetRamItemCount) of - 0 -> - {false, State}; - S1 -> - ReduceFuns = - case (AvgAckIngress - AvgAckEgress) > - (AvgIngress - AvgEgress) of - true -> - %% ACKs are growing faster than the queue, - %% push messages from there first. - [AckFun, AlphaBetaFun]; - false -> - %% The queue is growing faster than the - %% acks, push queue messages first. - [AlphaBetaFun, AckFun] - end, - {_, State2} = - %% Both reduce functions get a chance to reduce - %% memory. The second may very well get a quota of - %% 0 if the first function managed to push out the - %% maximum number of messages. - lists:foldl( - fun (ReduceFun, {QuotaN, StateN}) -> - ReduceFun(QuotaN, StateN) - end, {S1, State}, ReduceFuns), - {true, State2} + 0 -> {false, State}; + %% Reduce memory of pending acks and alphas. The order is + %% determined based on which is growing faster. Whichever + %% comes second may very well get a quota of 0 if the + %% first manages to push out the max number of messages. + S1 -> {_, State2} = + lists:foldl(fun (ReduceFun, {QuotaN, StateN}) -> + ReduceFun(QuotaN, StateN) + end, + {S1, State}, + case (AvgAckIngress - AvgAckEgress) > + (AvgIngress - AvgEgress) of + true -> [AckFun, AlphaBetaFun]; + false -> [AlphaBetaFun, AckFun] + end), + {true, State2} end, case State1 #vqstate.target_ram_item_count of |