Skip to content

Commit

Permalink
flush range on first only
Browse files Browse the repository at this point in the history
  • Loading branch information
cheme committed Apr 15, 2024
1 parent 24ba453 commit 25b1c1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,16 @@ impl IndexTable {
}

pub fn flush(&self) -> Result<()> {
// Flush everything except stats.
let mut start = META_SIZE;
let maps = self.map.read();
let mut first = true;
for map in maps.iter() {
try_io!(map.flush_range(start, map.len() - start)); // TODO not flush range when start 0
start = 0;
if first {
first = false;
// Flush everything except stats.
try_io!(map.flush_range(META_SIZE, map.len() - META_SIZE));
} else {
try_io!(map.flush());
}
}
Ok(())
}
Expand Down
12 changes: 8 additions & 4 deletions src/ref_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,16 @@ impl RefCountTable {
}

pub fn flush(&self) -> Result<()> {
// Flush everything except stats.
let mut start = META_SIZE;
let maps = self.map.read();
let mut first = true;
for map in maps.iter() {
try_io!(map.flush_range(start, map.len() - start)); // TODO not flush range when start 0
start = 0;
if first {
first = false;
// Flush everything except stats.
try_io!(map.flush_range(META_SIZE, map.len() - META_SIZE));
} else {
try_io!(map.flush());
}
}
Ok(())
}
Expand Down

0 comments on commit 25b1c1b

Please sign in to comment.