Skip to content

Commit 040ac0b

Browse files
committed
CQ: Remove paged out transient metrics
These metrics make a lot less sense in today's CQ implementation. Today messages are either in memory about to be sent to the consumer, or on disk because they are further down the queue. Messages are no longer paged out to disk depending on memory pressure. So knowing how many transient messages are on disk is not as important. In practice almost all of them will be.
1 parent 492fd41 commit 040ac0b

File tree

6 files changed

+39
-89
lines changed

6 files changed

+39
-89
lines changed

deps/rabbit/src/rabbit_backing_queue.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
message_bytes, message_bytes_ready,
1515
message_bytes_unacknowledged, message_bytes_ram,
1616
message_bytes_persistent, head_message_timestamp,
17-
disk_reads, disk_writes, backing_queue_status,
18-
messages_paged_out, message_bytes_paged_out]).
17+
disk_reads, disk_writes, backing_queue_status]).
1918

2019
%% We can't specify a per-queue ack/state with callback signatures
2120
-type ack() :: any().

deps/rabbit/src/rabbit_variable_queue.erl

Lines changed: 24 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
-export([start/2, stop/1]).
2323

2424
%% exported for testing only
25-
-export([start_msg_store/3, stop_msg_store/1, init/3]).
25+
-export([start_msg_store/3, stop_msg_store/1]).
2626

2727
-include("mc.hrl").
2828
-include_lib("stdlib/include/qlc.hrl").
@@ -144,7 +144,6 @@
144144
unacked_bytes,
145145
persistent_count, %% w unacked
146146
persistent_bytes, %% w unacked
147-
delta_transient_bytes, %%
148147

149148
ram_msg_count, %% w/o unacked
150149
ram_msg_count_prev,
@@ -204,7 +203,6 @@
204203
-record(q_tail,
205204
{ start_seq_id, %% start_seq_id is inclusive
206205
count,
207-
transient,
208206
end_seq_id %% end_seq_id is exclusive
209207
}).
210208

@@ -285,11 +283,9 @@
285283

286284
-define(BLANK_Q_TAIL, #q_tail { start_seq_id = undefined,
287285
count = 0,
288-
transient = 0,
289286
end_seq_id = undefined }).
290287
-define(BLANK_Q_TAIL_PATTERN(Z), #q_tail { start_seq_id = Z,
291288
count = 0,
292-
transient = 0,
293289
end_seq_id = Z }).
294290

295291
-define(MICROS_PER_SECOND, 1000000.0).
@@ -698,9 +694,6 @@ info(messages_ram, State) ->
698694
info(messages_ready_ram, State) + info(messages_unacknowledged_ram, State);
699695
info(messages_persistent, #vqstate{persistent_count = PersistentCount}) ->
700696
PersistentCount;
701-
%% @todo Remove.
702-
info(messages_paged_out, #vqstate{q_tail = #q_tail{transient = Count}}) ->
703-
Count;
704697
info(message_bytes, #vqstate{bytes = Bytes,
705698
unacked_bytes = UBytes}) ->
706699
Bytes + UBytes;
@@ -712,9 +705,6 @@ info(message_bytes_ram, #vqstate{ram_bytes = RamBytes}) ->
712705
RamBytes;
713706
info(message_bytes_persistent, #vqstate{persistent_bytes = PersistentBytes}) ->
714707
PersistentBytes;
715-
%% @todo Remove.
716-
info(message_bytes_paged_out, #vqstate{delta_transient_bytes = PagedOutBytes}) ->
717-
PagedOutBytes;
718708
info(head_message_timestamp, #vqstate{
719709
q_head = QHead,
720710
ram_pending_ack = RPA}) ->
@@ -994,28 +984,18 @@ is_msg_in_pending_acks(SeqId, #vqstate { ram_pending_ack = RPA,
994984
maps:is_key(SeqId, RPA) orelse
995985
maps:is_key(SeqId, DPA).
996986

997-
expand_q_tail(SeqId, ?BLANK_Q_TAIL_PATTERN(X), IsPersistent) ->
998-
qt(#q_tail{ start_seq_id = SeqId, count = 1, end_seq_id = SeqId + 1,
999-
transient = one_if(not IsPersistent)});
987+
expand_q_tail(SeqId, ?BLANK_Q_TAIL_PATTERN(X)) ->
988+
qt(#q_tail{ start_seq_id = SeqId, count = 1, end_seq_id = SeqId + 1 });
1000989
expand_q_tail(SeqId, #q_tail{ start_seq_id = StartSeqId,
1001-
count = Count,
1002-
transient = Transient } = QTail,
1003-
IsPersistent )
990+
count = Count } = QTail)
1004991
when SeqId < StartSeqId ->
1005-
qt(QTail #q_tail{ start_seq_id = SeqId, count = Count + 1,
1006-
transient = Transient + one_if(not IsPersistent)});
992+
qt(QTail #q_tail{ start_seq_id = SeqId, count = Count + 1 });
1007993
expand_q_tail(SeqId, #q_tail{ count = Count,
1008-
end_seq_id = EndSeqId,
1009-
transient = Transient } = QTail,
1010-
IsPersistent)
994+
end_seq_id = EndSeqId } = QTail)
1011995
when SeqId >= EndSeqId ->
1012-
qt(QTail #q_tail{ count = Count + 1, end_seq_id = SeqId + 1,
1013-
transient = Transient + one_if(not IsPersistent)});
1014-
expand_q_tail(_SeqId, #q_tail{ count = Count,
1015-
transient = Transient } = QTail,
1016-
IsPersistent ) ->
1017-
qt(QTail #q_tail{ count = Count + 1,
1018-
transient = Transient + one_if(not IsPersistent) }).
996+
qt(QTail #q_tail{ count = Count + 1, end_seq_id = SeqId + 1 });
997+
expand_q_tail(_SeqId, #q_tail{ count = Count } = QTail) ->
998+
qt(QTail #q_tail{ count = Count + 1 }).
1019999

10201000
%%----------------------------------------------------------------------------
10211001
%% Internal major helpers for Public API
@@ -1048,7 +1028,6 @@ init(IsDurable, IndexState, StoreState, DiskCount, DiskBytes, Terms,
10481028
true -> ?BLANK_Q_TAIL;
10491029
false -> qt(#q_tail { start_seq_id = LowSeqId,
10501030
count = DiskCount1,
1051-
transient = 0,
10521031
end_seq_id = NextSeqId })
10531032
end,
10541033
Now = erlang:monotonic_time(),
@@ -1073,7 +1052,6 @@ init(IsDurable, IndexState, StoreState, DiskCount, DiskBytes, Terms,
10731052
persistent_count = DiskCount1,
10741053
bytes = DiskBytes1,
10751054
persistent_bytes = DiskBytes1,
1076-
delta_transient_bytes = 0,
10771055

10781056
ram_msg_count = 0,
10791057
ram_msg_count_prev = 0,
@@ -1163,7 +1141,7 @@ stats_published_disk(MS = #msg_status{is_persistent = true}, St) ->
11631141
?UP(bytes, persistent_bytes, +msg_size(MS))};
11641142
stats_published_disk(MS = #msg_status{is_persistent = false}, St) ->
11651143
St#vqstate{?UP(len, +1),
1166-
?UP(bytes, delta_transient_bytes, +msg_size(MS))}.
1144+
?UP(bytes, +msg_size(MS))}.
11671145

11681146
%% Pending acks do not add to len. Messages are kept in memory.
11691147
stats_published_pending_acks(MS = #msg_status{is_persistent = true}, St) ->
@@ -1186,8 +1164,6 @@ stats_pending_acks(MS, St) ->
11861164

11871165
%% Message may or may not be persistent and the contents
11881166
%% may or may not be in memory.
1189-
%%
1190-
%% Removal from delta_transient_bytes is done by read_from_q_tail.
11911167
stats_removed(MS = #msg_status{is_persistent = true, msg = undefined}, St) ->
11921168
St#vqstate{?UP(len, persistent_count, -1),
11931169
?UP(bytes, persistent_bytes, -msg_size(MS))};
@@ -1237,7 +1213,6 @@ stats_requeued_disk(MS = #msg_status{is_persistent = true}, St) ->
12371213
?UP(bytes, +msg_size(MS)), ?UP(unacked_bytes, -msg_size(MS))};
12381214
stats_requeued_disk(MS = #msg_status{is_persistent = false}, St) ->
12391215
St#vqstate{?UP(len, +1),
1240-
?UP(bytes, delta_transient_bytes, +msg_size(MS)),
12411216
?UP(unacked_bytes, -msg_size(MS))}.
12421217

12431218
msg_size(#msg_status{msg_props = #message_properties{size = Size}}) -> Size.
@@ -1541,7 +1516,7 @@ publish1(Msg,
15411516
stats_published_memory(MsgStatus1, State2);
15421517
_ ->
15431518
{MsgStatus1, State1} = PersistFun(true, true, MsgStatus, State),
1544-
QTail1 = expand_q_tail(SeqId, QTail, IsPersistent),
1519+
QTail1 = expand_q_tail(SeqId, QTail),
15451520
State2 = State1 #vqstate { q_tail = QTail1 },
15461521
stats_published_disk(MsgStatus1, State2)
15471522
end,
@@ -1865,9 +1840,8 @@ q_tail_merge(SeqIds, QTail, MsgIds, State) ->
18651840
case msg_from_pending_ack(SeqId, State0) of
18661841
{none, _} ->
18671842
Acc;
1868-
{#msg_status { msg_id = MsgId,
1869-
is_persistent = IsPersistent } = MsgStatus, State1} ->
1870-
{expand_q_tail(SeqId, QTail0, IsPersistent), [MsgId | MsgIds0],
1843+
{#msg_status { msg_id = MsgId } = MsgStatus, State1} ->
1844+
{expand_q_tail(SeqId, QTail0), [MsgId | MsgIds0],
18711845
stats_requeued_disk(MsgStatus, State1)}
18721846
end
18731847
end, {QTail, MsgIds, State}, SeqIds).
@@ -1930,12 +1904,10 @@ read_from_q_tail(DelsAndAcksFun,
19301904
ram_msg_count = RamMsgCount,
19311905
ram_bytes = RamBytes,
19321906
disk_read_count = DiskReadCount,
1933-
delta_transient_bytes = DeltaTransientBytes,
19341907
transient_threshold = TransientThreshold },
19351908
MemoryLimit, WhatToRead) ->
19361909
#q_tail { start_seq_id = QTailSeqId,
19371910
count = QTailCount,
1938-
transient = Transient,
19391911
end_seq_id = QTailSeqIdEnd } = QTail,
19401912
%% For v2 we want to limit the number of messages read at once to lower
19411913
%% the memory footprint. We use the consume rate to determine how many
@@ -2012,7 +1984,7 @@ read_from_q_tail(DelsAndAcksFun,
20121984
metadata_only ->
20131985
{List0, StoreState, MCStateP, MCStateT}
20141986
end,
2015-
{QHead1, RamCountsInc, RamBytesInc, State1, TransientCount, TransientBytes} =
1987+
{QHead1, RamCountsInc, RamBytesInc, State1} =
20161988
become_q_head(List, TransientThreshold,
20171989
DelsAndAcksFun,
20181990
State #vqstate { index_state = IndexState1,
@@ -2036,17 +2008,13 @@ read_from_q_tail(DelsAndAcksFun,
20362008
0 ->
20372009
%% q_tail is now empty
20382010
State2 #vqstate { q_tail = ?BLANK_Q_TAIL,
2039-
q_head = QHead,
2040-
delta_transient_bytes = 0};
2011+
q_head = QHead };
20412012
N when N > 0 ->
20422013
QTail1 = qt(#q_tail { start_seq_id = QTailSeqId1,
2043-
count = N,
2044-
%% @todo Probably something wrong, seen it become negative...
2045-
transient = Transient - TransientCount,
2046-
end_seq_id = QTailSeqIdEnd }),
2014+
count = N,
2015+
end_seq_id = QTailSeqIdEnd }),
20472016
State2 #vqstate { q_head = QHead,
2048-
q_tail = QTail1,
2049-
delta_transient_bytes = DeltaTransientBytes - TransientBytes }
2017+
q_tail = QTail1 }
20502018
end
20512019
end.
20522020

@@ -2070,30 +2038,27 @@ merge_sh_read_msgs(MTail, _Reads) ->
20702038
MTail.
20712039

20722040
become_q_head(List, TransientThreshold, DelsAndAcksFun, State = #vqstate{ next_deliver_seq_id = NextDeliverSeqId0 }) ->
2073-
{Filtered, NextDeliverSeqId, Acks, RamReadyCount, RamBytes, TransientCount, TransientBytes} =
2041+
{Filtered, NextDeliverSeqId, Acks, RamReadyCount, RamBytes} =
20742042
lists:foldr(
20752043
fun ({_MsgOrId, SeqId, _MsgLocation, _MsgProps, IsPersistent} = M,
2076-
{Filtered1, NextDeliverSeqId1, Acks1, RRC, RB, TC, TB} = Acc) ->
2044+
{Filtered1, NextDeliverSeqId1, Acks1, RRC, RB} = Acc) ->
20772045
case SeqId < TransientThreshold andalso not IsPersistent of
20782046
true -> {Filtered1,
20792047
next_deliver_seq_id(SeqId, NextDeliverSeqId1),
2080-
[SeqId | Acks1], RRC, RB, TC, TB};
2048+
[SeqId | Acks1], RRC, RB};
20812049
false -> MsgStatus = m(msg_status(M)),
20822050
HaveMsg = msg_in_ram(MsgStatus),
20832051
Size = msg_size(MsgStatus),
20842052
case is_msg_in_pending_acks(SeqId, State) of
20852053
false -> {?QUEUE:in_r(MsgStatus, Filtered1),
20862054
NextDeliverSeqId1, Acks1,
20872055
RRC + one_if(HaveMsg),
2088-
RB + one_if(HaveMsg) * Size,
2089-
TC + one_if(not IsPersistent),
2090-
TB + one_if(not IsPersistent) * Size};
2056+
RB + one_if(HaveMsg) * Size};
20912057
true -> Acc %% [0]
20922058
end
20932059
end
2094-
end, {?QUEUE:new(), NextDeliverSeqId0, [], 0, 0, 0, 0}, List),
2095-
{Filtered, RamReadyCount, RamBytes, DelsAndAcksFun(NextDeliverSeqId, Acks, State),
2096-
TransientCount, TransientBytes}.
2060+
end, {?QUEUE:new(), NextDeliverSeqId0, [], 0, 0}, List),
2061+
{Filtered, RamReadyCount, RamBytes, DelsAndAcksFun(NextDeliverSeqId, Acks, State)}.
20972062
%% [0] We don't increase RamBytes here, even though it pertains to
20982063
%% unacked messages too, since if HaveMsg then the message must have
20992064
%% been stored in the QI, thus the message must have been in

deps/rabbit/test/backing_queue_SUITE.erl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,14 +1185,14 @@ variable_queue_partial_segments_q_tail_thing2(VQ0, _QName) ->
11851185
%% We only have one message in memory because the amount in memory
11861186
%% depends on the consume rate, which is nil in this test.
11871187
[{q_head, 1},
1188-
{q_tail, {q_tail, 1, OneAndAHalfSegment - 1, 0, OneAndAHalfSegment}},
1188+
{q_tail, {q_tail, 1, OneAndAHalfSegment - 1, OneAndAHalfSegment}},
11891189
{len, OneAndAHalfSegment}]),
11901190
VQ5 = check_variable_queue_status(
11911191
variable_queue_publish(true, 1, VQ3),
11921192
%% one alpha, but it's in the same segment as the q_tail
11931193
%% @todo That's wrong now! v1/v2
11941194
[{q_head, 1},
1195-
{q_tail, {q_tail, 1, OneAndAHalfSegment, 0, OneAndAHalfSegment + 1}},
1195+
{q_tail, {q_tail, 1, OneAndAHalfSegment, OneAndAHalfSegment + 1}},
11961196
{len, OneAndAHalfSegment + 1}]),
11971197
{VQ6, AckTags} = variable_queue_fetch(SegmentSize, true, false,
11981198
SegmentSize + HalfSegment + 1, VQ5),
@@ -1202,7 +1202,7 @@ variable_queue_partial_segments_q_tail_thing2(VQ0, _QName) ->
12021202
%% after fetching exactly one segment, we should have no
12031203
%% messages in memory.
12041204
[{q_head, 0},
1205-
{q_tail, {q_tail, SegmentSize, HalfSegment + 1, 0, OneAndAHalfSegment + 1}},
1205+
{q_tail, {q_tail, SegmentSize, HalfSegment + 1, OneAndAHalfSegment + 1}},
12061206
{len, HalfSegment + 1}]),
12071207
{VQ8, AckTags1} = variable_queue_fetch(HalfSegment + 1, true, false,
12081208
HalfSegment + 1, VQ7),
@@ -1769,7 +1769,7 @@ with_fresh_variable_queue(Fun, Mode) ->
17691769
VQ = variable_queue_init(test_amqqueue(QName, true), false),
17701770
S0 = variable_queue_status(VQ),
17711771
assert_props(S0, [{q_head, 0},
1772-
{q_tail, {q_tail, undefined, 0, 0, undefined}},
1772+
{q_tail, {q_tail, undefined, 0, undefined}},
17731773
{len, 0}]),
17741774
VQ1 = set_queue_mode(Mode, VQ),
17751775
try
@@ -1914,9 +1914,9 @@ variable_queue_with_holes(VQ0) ->
19141914
vq_with_holes_assertions(VQ) ->
19151915
[false =
19161916
case V of
1917-
{q_tail, _, 0, _, _} -> true;
1918-
0 -> true;
1919-
_ -> false
1917+
{q_tail, _, 0, _} -> true;
1918+
0 -> true;
1919+
_ -> false
19201920
end || {K, V} <- variable_queue_status(VQ),
19211921
lists:member(K, [q_head, q_tail])].
19221922

deps/rabbitmq_management/priv/www/js/tmpl/classic-queue-stats.ejs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
<th class="horizontal">Unacked</th>
3535
<th class="horizontal">In memory</th>
3636
<th class="horizontal">Persistent</th>
37-
<th class="horizontal">Transient, Paged Out</th>
3837
</tr>
3938
<tr>
4039
<th>
@@ -56,9 +55,6 @@
5655
<td class="r">
5756
<%= fmt_num_thousands(queue.messages_persistent) %>
5857
</td>
59-
<td class="r">
60-
<%= fmt_num_thousands(queue.messages_paged_out) %>
61-
</td>
6258
</tr>
6359
<tr>
6460
<th>
@@ -80,9 +76,6 @@
8076
<td class="r">
8177
<%= fmt_bytes(queue.message_bytes_persistent) %>
8278
</td>
83-
<td class="r">
84-
<%= fmt_bytes(queue.message_bytes_paged_out) %>
85-
</td>
8679
</tr>
8780
<tr>
8881
<th>

deps/rabbitmq_prometheus/metrics.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ These metrics are specific to the stream protocol.
188188
| rabbitmq_queue_disk_writes_total | Total number of times queue wrote messages to disk |
189189
| rabbitmq_queue_messages | Sum of ready and unacknowledged messages - total queue depth |
190190
| rabbitmq_queue_messages_bytes | Size in bytes of ready and unacknowledged messages |
191-
| rabbitmq_queue_messages_paged_out | Messages paged out to disk |
192-
| rabbitmq_queue_messages_paged_out_bytes | Size in bytes of messages paged out to disk |
193191
| rabbitmq_queue_messages_persistent | Persistent messages |
194192
| rabbitmq_queue_messages_persistent_bytes | Size in bytes of persistent messages |
195193
| rabbitmq_queue_messages_published_total | Total number of messages published to queues |

0 commit comments

Comments
 (0)