diff options
author | Rob Harrop <rob@rabbitmq.com> | 2010-11-05 00:11:30 +0000 |
---|---|---|
committer | Rob Harrop <rob@rabbitmq.com> | 2010-11-05 00:11:30 +0000 |
commit | 6fde9cbafc73040b33cb750a8e429209df1ae473 (patch) | |
tree | 1554f44168dc194721d5f407adb6877b893af28b | |
parent | e8821b7480c0c2df2536571647b1ed012ddc58f3 (diff) | |
download | rabbitmq-server-6fde9cbafc73040b33cb750a8e429209df1ae473.tar.gz |
Cosmetic change and first draft of comment updates
-rw-r--r-- | src/rabbit_variable_queue.erl | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index 57d1344e..8b36767c 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -168,6 +168,22 @@ %% the latter) are both cheap and do require any scanning through qi %% segments. %% +%% Pending acks are recorded in memory either as the tuple {SeqId, +%% Guid, MsgProps} (tuple form) or as the message itself (message +%% form). Acks for persistent messages are always stored in the tuple +%% form. Acks for transient messages are also stored in tuple form if +%% the message has been forgotten to disk as part of the memory +%% reduction process. For transient messages that haven't already been +%% written to disk, acks are stored in message form to avoid the +%% overhead of writing to disk. +%% +%% During memory reduction, messages stored as transient ack records +%% are pushed out to disk before messages in the queue. More +%% precisely, messages from the queue will not be pushed out to disk +%% while the number of messages stored for acks is greater than +%% zero. Messages for acks are written to disk in batches of at most +%% ?IO_BATCH_SIZE. +%% %% Notes on Clean Shutdown %% (This documents behaviour in variable_queue, queue_index and %% msg_store.) @@ -1347,7 +1363,20 @@ find_persistent_count(LensByStore) -> %% 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, BetaGammaFun, BetaDeltaFun, AckFun, State) -> - {ReduceAck, State1} = reduce_ack_memory_use(AckFun, State), + {Reduce, State2} = case reduce_ack_memory_use(AckFun, State) of + {true, State1} -> + %% Don't want to reduce the number of + %% ram messages if we might yet be able + %% to reduce more acks. + {true, State1}; + {false, State1} -> + case chunk_size( + State1 #vqstate.ram_msg_count, + State1 #vqstate.target_ram_msg_count) of + 0 -> {false, State1}; + S1 -> {true, AlphaBetaFun(S1, State1)} + end + end, {Reduce, State2} = case ReduceAck of true -> |