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 incorrect heap size calculation #55

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/fm_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ where
///
/// No suffix array information is stored in this index.
pub fn size(&self) -> usize {
std::mem::size_of::<Self>()
+ self.bw.heap_size()
+ self.cs.len() * std::mem::size_of::<Vec<u64>>()
self.bw.heap_size() + self.cs.capacity() * std::mem::size_of::<u64>()
}
}

Expand All @@ -120,9 +118,8 @@ where
///
/// Sampled suffix array data is stored in this index.
pub fn size(&self) -> usize {
Copy link
Owner Author

@ajalab ajalab Feb 11, 2025

Choose a reason for hiding this comment

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

Maybe the name of this method size is a bit vague. Should we name it heap_size like vers-vec?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd be happy to see this change!

Copy link
Owner Author

Choose a reason for hiding this comment

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

Filed #58 not to forget.

std::mem::size_of::<Self>()
+ self.bw.heap_size()
+ self.cs.len() * std::mem::size_of::<Vec<u64>>()
self.bw.heap_size()
+ self.cs.capacity() * std::mem::size_of::<u64>()
+ self.suffix_array.size()
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/rlfmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@ where
///
/// No suffix array information is stored in this index.
pub fn size(&self) -> usize {
std::mem::size_of::<Self>()
+ self.s.heap_size()
self.s.heap_size()
+ self.b.heap_size()
+ self.bp.heap_size()
+ self.cs.len() * std::mem::size_of::<Vec<u64>>()
+ self.cs.capacity() * std::mem::size_of::<u64>()
}
}

Expand All @@ -166,11 +165,10 @@ where
///
/// Sampled suffix array data is stored in this index.
pub fn size(&self) -> usize {
std::mem::size_of::<Self>()
+ self.s.heap_size()
self.s.heap_size()
+ self.b.heap_size()
+ self.bp.heap_size()
+ self.cs.len() * std::mem::size_of::<Vec<u64>>()
+ self.cs.capacity() * std::mem::size_of::<u64>()
+ self.suffix_array.size()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/suffix_array/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl SuffixOrderSampledArray {
}

pub(crate) fn size(&self) -> usize {
std::mem::size_of::<Self>() + self.sa.heap_size()
self.sa.heap_size()
}
}

Expand Down