Skip to content

Commit

Permalink
s/disk_log_impl: added log segment size jitter
Browse files Browse the repository at this point in the history
Added small jitter to requested log segment size to make sure that we do
not roll all segments of evenly loaded partition at once.

Signed-off-by: Michal Maslanka <michal@vectorized.io>
  • Loading branch information
mmaslankaprv committed Nov 5, 2020
1 parent b646f9e commit aa81362
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/v/storage/disk_log_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ disk_log_impl::disk_log_impl(
, _segs(std::move(segs))
, _kvstore(kvstore)
, _start_offset(read_start_offset())
, _lock_mngr(_segs) {
, _lock_mngr(_segs)
, _max_segment_size(internal::jitter_segment_size(max_segment_size())) {
const bool is_compacted = config().is_compacted();
for (auto& s : _segs) {
_probe.add_initial_segment(*s);
Expand Down Expand Up @@ -442,7 +443,7 @@ size_t disk_log_impl::bytes_left_before_roll() const {
return 0;
}
auto fo = back->appender().file_byte_offset();
auto max = max_segment_size();
auto max = _max_segment_size;
if (fo >= max) {
return 0;
}
Expand All @@ -460,8 +461,8 @@ ss::future<> disk_log_impl::maybe_roll(
return new_segment(next_offset, t, iopc);
}
bool size_should_roll = false;
const auto max = max_segment_size();
if (ptr->appender().file_byte_offset() >= max) {

if (ptr->appender().file_byte_offset() >= _max_segment_size) {
size_should_roll = true;
}
if (t != term() || size_should_roll) {
Expand Down
1 change: 1 addition & 0 deletions src/v/storage/disk_log_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class disk_log_impl final : public log::impl {
failure_probes _failure_probes;
std::optional<eviction_monitor> _eviction_monitor;
model::offset _max_collectible_offset;
size_t _max_segment_size;
};

} // namespace storage

0 comments on commit aa81362

Please sign in to comment.