-
Notifications
You must be signed in to change notification settings - Fork 196
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
Reduce memory usage for strings in inode metadata #1346
Conversation
Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple of questions and I'd wait for benchmark results, but otherwise LGTM
@@ -344,9 +344,9 @@ impl InodeStat { | |||
/// restored, and so we override their permissions to 000 and reject reads to them. We also warn | |||
/// the first time we see an object like this, because FUSE enforces the 000 permissions on our | |||
/// behalf so we might not see an attempted `open` call. | |||
fn is_readable(storage_class: Option<String>, restore_status: Option<RestoreStatus>) -> bool { | |||
fn is_readable(storage_class: Option<&str>, restore_status: Option<RestoreStatus>) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
storage_class
is still stored as String
right? (don't see it changed to Box<str>
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not store it in the inodes, it's only used here to determine the is_readable
flag.
// Allocate the new string with the correct capacity. | ||
let mut key = | ||
String::with_capacity(name_offset + name.len() + if kind == InodeKind::Directory { 1 } else { 0 }); | ||
key.push_str(&self.key); | ||
key.push_str(&name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ensures that no slack capacity is wasted
regarding this aspect from the description, do you think slack capacity was added here, when pushing to the string? my assumption would be that initial allocation self.as_ref().to_owned()
would use exactly the right amount of memory, so for etag
and storage_class
the saving is exactly one usize
(previously used to track capacity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the slack capacity savings are only for keys. For etag
and the children names we only save the usize
field.
Reduce memory usage for strings included in inode metadata, like object keys, etags, and inode names. Using a
Box<str>
instead of aString
ensures that no slack capacity is wasted and saves theusize
field to keep track of the buffer capacity.Does this change impact existing behavior?
No functional changes.
Does this change need a changelog entry? Does it require a version change?
Yes.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).