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

Reduce memory used to store inode names #1305

Merged
merged 2 commits into from
Mar 13, 2025
Merged

Conversation

passaro
Copy link
Contributor

@passaro passaro commented Mar 6, 2025

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 type ValidName) 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).

@passaro passaro temporarily deployed to PR integration tests March 6, 2025 15:59 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 6, 2025 15:59 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 6, 2025 15:59 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 6, 2025 15:59 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 6, 2025 15:59 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 6, 2025 15:59 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 6, 2025 15:59 — with GitHub Actions Inactive
vladem
vladem previously approved these changes Mar 12, 2025
Copy link
Contributor

@vladem vladem left a 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()
Copy link
Contributor

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<'_> {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

passaro added 2 commits March 13, 2025 08:04
Signed-off-by: Alessandro Passaro <[email protected]>
@passaro passaro temporarily deployed to PR integration tests March 13, 2025 08:22 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 13, 2025 08:22 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 13, 2025 08:22 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 13, 2025 08:22 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 13, 2025 08:22 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 13, 2025 08:22 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests March 13, 2025 08:22 — with GitHub Actions Inactive
@passaro passaro enabled auto-merge March 13, 2025 09:02
@passaro passaro requested a review from vladem March 13, 2025 10:22
@passaro passaro added this pull request to the merge queue Mar 13, 2025
Merged via the queue into awslabs:main with commit 5a74b44 Mar 13, 2025
26 checks passed
@passaro passaro deleted the mem/key-metadata branch March 13, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants