Skip to content

Commit

Permalink
raftstore: optimize region destroy (tikv#13384)
Browse files Browse the repository at this point in the history
close tikv#12421

Optimize the performance of merging empty regions

Signed-off-by: tabokie <xy.tao@outlook.com>
  • Loading branch information
tabokie committed Sep 6, 2022
1 parent 80093e3 commit 4bdf5f3
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions components/engine_rocks/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ impl RocksEngine {
) -> Result<()> {
let mut ranges = ranges.to_owned();
ranges.sort_by(|a, b| a.start_key.cmp(b.start_key));
let max_end_key = ranges
.iter()
.fold(ranges[0].end_key, |x, y| std::cmp::max(x, y.end_key));
let start = KeyBuilder::from_slice(ranges[0].start_key, 0, 0);
let end = KeyBuilder::from_slice(max_end_key, 0, 0);
let mut opts = IterOptions::new(Some(start), Some(end), false);
if self.is_titan() {
// Cause DeleteFilesInRange may expose old blob index keys, setting key only for Titan
// to avoid referring to missing blob files.
opts.set_key_only(true);
}

let mut writer_wrapper: Option<RocksSstWriter> = None;
let mut data: Vec<Vec<u8>> = vec![];
Expand All @@ -55,7 +44,17 @@ impl RocksEngine {
}
last_end_key = Some(r.end_key.to_owned());

let mut it = self.iterator_cf_opt(cf, opts.clone())?;
let mut opts = IterOptions::new(
Some(KeyBuilder::from_slice(r.start_key, 0, 0)),
Some(KeyBuilder::from_slice(r.end_key, 0, 0)),
false,
);
if self.is_titan() {
// Cause DeleteFilesInRange may expose old blob index keys, setting key only for
// Titan to avoid referring to missing blob files.
opts.set_key_only(true);
}
let mut it = self.iterator_cf_opt(cf, opts)?;
let mut it_valid = it.seek(r.start_key.into())?;
while it_valid {
if it.key() >= r.end_key {
Expand Down

0 comments on commit 4bdf5f3

Please sign in to comment.