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

fix(storage): fix calculate incorrect memory usage of sstable meta #8126

Merged
merged 2 commits into from Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/storage/src/hummock/sstable/mod.rs
Expand Up @@ -193,7 +193,7 @@ impl Sstable {

#[inline]
pub fn estimate_size(&self) -> usize {
8 /* id */ + self.meta.encoded_size()
8 /* id */ + self.filter_reader.estimate_size() + self.meta.encoded_size()
}

#[cfg(test)]
Expand Down
4 changes: 4 additions & 0 deletions src/storage/src/hummock/sstable/xor_filter.rs
Expand Up @@ -103,6 +103,10 @@ impl XorFilterReader {
}
}

pub fn estimate_size(&self) -> usize {
self.filter.fingerprints.len() * std::mem::size_of::<u16>()
}

pub fn is_empty(&self) -> bool {
self.filter.block_length == 0
}
Expand Down
2 changes: 1 addition & 1 deletion src/storage/src/hummock/sstable_store.rs
Expand Up @@ -346,7 +346,7 @@ impl SstableStore {
.map_err(HummockError::object_io_error)?;
let meta = SstableMeta::decode(&mut &buf[..])?;
let sst = Sstable::new(sst_id, meta);
let charge = sst.meta.encoded_size();
let charge = sst.estimate_size();
let add = (now.elapsed().as_secs_f64() * 1000.0).ceil();
stats_ptr.fetch_add(add as u64, Ordering::Relaxed);
Ok((Box::new(sst), charge))
Expand Down