-
Notifications
You must be signed in to change notification settings - Fork 192
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 used to store inode names #1305
Conversation
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.
lgtm, a couple of questions, non-blocking
@@ -63,15 +58,19 @@ impl Inode { | |||
} | |||
|
|||
pub fn name(&self) -> &str { | |||
&self.inner.name | |||
self.inner.valid_key.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.
nice!
} | ||
} | ||
|
||
impl Deref for ValidName<'_> { |
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 bit non-intuitive that *valid_name
and &valid_name
are both &str
, where do we need Deref
implementation?
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.
Deref
also gives us all the methods on &str
, see Deref coercion.
Signed-off-by: Alessandro Passaro <[email protected]>
Signed-off-by: Alessandro Passaro <[email protected]>
d31a017
to
fd75035
Compare
Each inode currently stores two separate strings for the key and the name (always contained in the key string), resulting in redundant memory usage. This change introduces a new
ValidKey
type which avoids the duplication by only storing the key and the offset of the name for O(1) retrieval.ValidKey
(and the related typeValidName
) also enforce validation for the name and the whole key at construction time, allowing calling code to rely on the strings to be well-formed.Does this change impact existing behavior?
No.
Does this change need a changelog entry? Does it require a version change?
No.
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).