summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2011-10-22 14:12:19 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2011-10-22 14:12:19 +0100
commited08095a7073c02989a8d869d0a07e300f24f79b (patch)
treea0b68e4141ebe105317ec8874543ca0442e35429
parent4f6e0ab239abf75b7f391f71590c2d09c616f34e (diff)
downloadrabbitmq-server-ed08095a7073c02989a8d869d0a07e300f24f79b.tar.gz
minor optimisation: switch from dict to gb_trees
...for the msg_id_to_channel map in the queue process. This doesn't actually produce any noticable gain, but we use gb_sets/trees everywhere else in the 'confirm' logic and this was the only place in the code where a dict was keyed on msg_ids.
-rw-r--r--src/rabbit_amqqueue_process.erl12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index ec1a9b77..ba20b355 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -129,7 +129,7 @@ init(Q) ->
rate_timer_ref = undefined,
expiry_timer_ref = undefined,
ttl = undefined,
- msg_id_to_channel = dict:new()},
+ msg_id_to_channel = gb_trees:empty()},
{ok, rabbit_event:init_stats_timer(State, #q.stats_timer), hibernate,
{backoff, ?HIBERNATE_AFTER_MIN, ?HIBERNATE_AFTER_MIN, ?DESIRED_HIBERNATE}}.
@@ -454,11 +454,11 @@ confirm_messages(MsgIds, State = #q{msg_id_to_channel = MTC}) ->
{CMs, MTC1} =
lists:foldl(
fun(MsgId, {CMs, MTC0}) ->
- case dict:find(MsgId, MTC0) of
- {ok, {ChPid, MsgSeqNo}} ->
+ case gb_trees:lookup(MsgId, MTC0) of
+ {value, {ChPid, MsgSeqNo}} ->
{rabbit_misc:gb_trees_cons(ChPid, MsgSeqNo, CMs),
- dict:erase(MsgId, MTC0)};
- _ ->
+ gb_trees:delete(MsgId, MTC0)};
+ none ->
{CMs, MTC0}
end
end, {gb_trees:empty(), MTC}, MsgIds),
@@ -482,7 +482,7 @@ needs_confirming(_) -> false.
maybe_record_confirm_message({eventually, ChPid, MsgSeqNo, MsgId},
State = #q{msg_id_to_channel = MTC}) ->
- State#q{msg_id_to_channel = dict:store(MsgId, {ChPid, MsgSeqNo}, MTC)};
+ State#q{msg_id_to_channel = gb_trees:insert(MsgId, {ChPid, MsgSeqNo}, MTC)};
maybe_record_confirm_message(_Confirm, State) ->
State.