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

TmpFs Memory Usage Tracking and Limiting #3902

Merged
merged 3 commits into from
May 24, 2023

Conversation

theduke
Copy link
Contributor

@theduke theduke commented May 24, 2023

feat(virtual-fs): Add TmpFs memory tracking and limiting

Hacky implementation for tracking and limiting the memory consumption of
in-memory files of the TmpFs / mem_fs.

Ideally this would use a Vec with a custom allocator, but the allocator
APIs are currently restricted to nightly Rust.

To keep both code impact and performance impact low, a TrackedVec is
added that can hold a FsMemoryLimiter, which has callbacks for growing
and for shrinking memory.

Without the new "tracked" feature enabled, a stub impl is added, which
does not do any tracking , and hence has minimal performance impact.

This should be rewritten to a sane implementaiton soon as part of a
larger virtual-fs rewrite.

Closes #3865

theduke added 2 commits May 24, 2023 11:30
Hacky implementation for tracking and limiting the memory consumption of
in-memory files of the TmpFs / mem_fs.

Ideally this would use a Vec with a custom allocator, but the allocator
APIs are currently restricted to nightly Rust.

To keep both code impact and performance impact low, a TrackedVec is
added that can hold a FsMemoryLimiter, which has callbacks for growing
and for shrinking memory.

Without the new "tracked" feature enabled, a stub impl is added, which
does not do any tracking , and hence has minimal performance impact.

This should be rewritten to a sane implementaiton soon as part of a
larger virtual-fs rewrite.

Part of #3865
Allows users to set a memory limiter for limiting temp fs memory usage
when using the Console.

Part of #3865
@theduke theduke requested a review from ptitSeb May 24, 2023 09:36
Need to shrink by capacity, not by len.
@theduke theduke enabled auto-merge (rebase) May 24, 2023 10:15
@theduke theduke merged commit 1c2a4b0 into master May 24, 2023
@theduke theduke deleted the issue-3865-memfs-size-tracking-callback branch May 24, 2023 11:04
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.

vfs: Parameterize memfs With Custom Allocator
2 participants