-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raftstore: restrict the total write size of each apply round #13594
Changes from 5 commits
d337d1c
7cfaa78
953211f
5192183
5343ce3
18e70bc
b2909a2
c6863e3
72aa623
b628ac2
2aa32d8
9e76488
aa70d4f
ca6b1bd
11f392e
173c59a
5ac4ca2
9eb1f79
2dfbd8e
a56e49c
9e93876
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3386,6 +3386,13 @@ where | |
merge_from_snapshot, | ||
}) | ||
} | ||
|
||
pub fn entries_size(&self) -> usize { | ||
match self { | ||
Msg::Apply { apply, .. } => apply.entries_size, | ||
_ => 0, | ||
} | ||
} | ||
} | ||
|
||
impl<EK> Debug for Msg<EK> | ||
|
@@ -4043,6 +4050,7 @@ where | |
msg_buf: Vec<Msg<EK>>, | ||
apply_ctx: ApplyContext<EK>, | ||
messages_per_tick: usize, | ||
messages_size_per_tick: usize, | ||
cfg_tracker: Tracker<Config>, | ||
|
||
trace_event: TraceEvent, | ||
|
@@ -4068,6 +4076,7 @@ where | |
} | ||
_ => {} | ||
} | ||
self.messages_size_per_tick = incoming.messages_size_per_tick; | ||
update_cfg(&incoming.apply_batch_system); | ||
} | ||
} | ||
|
@@ -4112,9 +4121,15 @@ where | |
normal.delegate.id() == 1003, | ||
|_| { HandleResult::KeepProcessing } | ||
); | ||
while self.msg_buf.len() < self.messages_per_tick { | ||
let mut total_size = 0; | ||
while self.msg_buf.len() < self.messages_per_tick | ||
&& total_size < self.messages_size_per_tick | ||
{ | ||
match normal.receiver.try_recv() { | ||
Ok(msg) => self.msg_buf.push(msg), | ||
Ok(msg) => { | ||
total_size += msg.entries_size(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not check batch size directly by moving the handle task logic into this loop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I don't get your point. Are there any benifit to do so? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. msg's size doesn't mean the real size written to db, but batch size does |
||
self.msg_buf.push(msg); | ||
} | ||
Err(TryRecvError::Empty) => { | ||
handle_result = HandleResult::stop_at(0, false); | ||
break; | ||
|
@@ -4211,6 +4226,7 @@ where | |
priority, | ||
), | ||
messages_per_tick: cfg.messages_per_tick, | ||
messages_size_per_tick: cfg.messages_size_per_tick, | ||
cfg_tracker: self.cfg.clone().tracker(self.tag.clone()), | ||
trace_event: Default::default(), | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Size configuration should be defined as
ReadableSize
.