Skip to content
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

enlarge append recycle log threshold #331

Merged
merged 8 commits into from
Sep 7, 2023
Merged

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Sep 1, 2023

  • This PR change the recycle log threshold from (purge_threshold / target_file_size) + 2 to (purge_threshold / target_file_size)*1.5 to avoid repeatedly creating and purging log files when tikv's log compaction has non-trivial latency.
  • Also changes the prefill_limit's semantic meaning, after this change, it will means the total log files threshold instead of recycle files threshold.

Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
@glorv glorv requested a review from tabokie September 1, 2023 10:10
@glorv
Copy link
Contributor Author

glorv commented Sep 1, 2023

@LykxSassinator PTAL thanks~

@codecov
Copy link

codecov bot commented Sep 1, 2023

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
src/config.rs 100.00%
src/engine.rs 100.00%

📢 Thoughts on this report? Let us know!.

Copy link
Contributor

@LykxSassinator LykxSassinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -241,7 +241,7 @@ impl Config {
if self.prefill_for_recycle && prefill_limit >= self.target_file_size.0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When prefill_limit is None, use recycle_capacity.

);
let to_create = target.saturating_sub(self.recycled_files.len());
let prefill_target =
std::cmp::min(self.cfg.prefill_capacity(), self.cfg.recycle_capacity())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the same as old code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the old code is not fit anymore after the recycle threshold is enlarged. From @LykxSassinator, the old logic is that prefill_capacity is the number of recycle files that should be pre-created even if there are already some append files; but the new logic changes the semantic to let prefill_capacity the total files number (recycle + append), I think this is more intuitive.
In the general case, we expect the total files size is around the size of purge threshold but not the recycle threshold ( 1.5 * purge_threshold), so it's better not to pre-create too many redundant files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we expect the total files size is around the size of purge threshold but not the recycle threshold ( 1.5 * purge_threshold)

I don't think so. We need to prepare the same amount of files as recycle-threshold. The condition where a large recycle-threshold is needed can also occur when raft-engine has just started.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I changed the default prefill threshold to recycle-threshold.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a bug in the old code that it only count the recycle file to create prefill files count. While with the default config there is no problem because it is equal to the recycle threshold. But if the prefill threshold is smaller than recycle threshold, I can cause raft-engine to create more files after restarting which is unexpacted. One of the log recycle test case failed after I exlarged the recycle threshold.

Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
src/engine.rs Outdated
@@ -2197,11 +2197,11 @@ pub(crate) mod tests {
assert_eq!(reserved_start_2, reserved_start_3);

// Reuse all of reserved files.
for rid in 1..=50 {
for rid in 1..=75 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for rid in 1..=75 {
for rid in 1..=cfg.recycled_capacity() {

);
let to_create = target.saturating_sub(self.recycled_files.len());
let prefill_target =
std::cmp::min(self.cfg.prefill_capacity(), self.cfg.recycle_capacity())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old logic is that prefill_capacity is the number of recycle files that should be pre-created even if there are already some append files; but the new logic changes the semantic to let prefill_capacity the total files number (recycle + append), I think this is more intuitive.

This doesn't seem more intuitive to me. The prefill_limit stands for the amount of data that user can tolerate to write before startup. It should not be subtracted with append files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I reverted this change as the default purge_threshold and recycle_threshold is still the same.

Signed-off-by: glorv <glorvs@163.com>
@tabokie tabokie merged commit ec6aa90 into tikv:master Sep 7, 2023
@glorv glorv deleted the recycle-threshold branch September 7, 2023 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants