Skip to content

Commit 8e4a3aa

Browse files
committed
Try evaluating byte size independently of time window
also increase max size
1 parent d2a294e commit 8e4a3aa

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

deps/rabbit/src/rabbit_fifo.erl

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,28 +2948,33 @@ do_checkpoints(Ts, #checkpoint{index = ChIdx,
29482948
MsgsTot = messages_total(MacState),
29492949
%% more than 64MB (by default) of message data has been written to the log
29502950
%% best take a checkpoint
2951-
EnoughDataWritten = BytesIn - LastBytesIn > ?CHECK_MAX_BYTES,
29522951

29532952
{CheckMinInterval, CheckMinIndexes, CheckMaxIndexes} =
29542953
persistent_term:get(quorum_queue_checkpoint_config,
29552954
{?CHECK_MIN_INTERVAL_MS, ?CHECK_MIN_INDEXES,
29562955
?CHECK_MAX_INDEXES}),
2956+
2957+
%% scale the bytes limit as the backlog increases
2958+
MaxBytesFactor = max(1, MsgsTot / CheckMaxIndexes),
2959+
EnoughDataWritten = BytesIn - LastBytesIn > (?CHECK_MAX_BYTES * MaxBytesFactor),
29572960
EnoughTimeHasPassed = TimeSince > CheckMinInterval,
29582961

2959-
case EnoughTimeHasPassed andalso
2960-
(
2961-
%% condition 1: enough indexes have been committed since the last
2962-
%% checkpoint
2963-
(IndexesSince > MinIndexes) orelse
2964-
%% condition 2: the queue is empty and _some_ commands
2965-
%% have been applied since the last checkpoint
2966-
(MsgsTot == 0 andalso IndexesSince > 32) orelse
2967-
%% condition 3: enough message data has been written to warrant a new
2968-
%% checkpoint
2969-
EnoughDataWritten orelse
2970-
%% force was requested, e.g. after a purge
2971-
Force
2972-
) of
2962+
case (EnoughTimeHasPassed andalso
2963+
(
2964+
%% condition 1: enough indexes have been committed since the last
2965+
%% checkpoint
2966+
(IndexesSince > MinIndexes) orelse
2967+
%% condition 2: the queue is empty and _some_ commands
2968+
%% have been applied since the last checkpoint
2969+
(MsgsTot == 0 andalso IndexesSince > 32)
2970+
)
2971+
) orelse
2972+
%% condition 3: enough message data has been written to warrant a new
2973+
%% checkpoint, this ignores the time windowing
2974+
EnoughDataWritten orelse
2975+
%% force was requested, e.g. after a purge
2976+
Force
2977+
of
29732978
true ->
29742979
%% take fewer checkpoints the more messages there are on queue
29752980
NextIndexes = min(max(MsgsTot, CheckMinIndexes), CheckMaxIndexes),

deps/rabbit/src/rabbit_fifo.hrl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
-define(CHECK_MAX_INDEXES, 666_667).
105105
%% once these many bytes have been written since the last checkpoint
106106
%% we request a checkpoint irrespectively
107-
-define(CHECK_MAX_BYTES, 64_000_000).
107+
-define(CHECK_MAX_BYTES, 128_000_000).
108108

109109
-define(USE_AVG_HALF_LIFE, 10000.0).
110110
%% an average QQ without any message uses about 100KB so setting this limit

0 commit comments

Comments
 (0)