Skip to content

storage: close idle open FDs via FileManager#834

Open
j-c-m wants to merge 1 commit into
rakshasa:masterfrom
j-c-m:feature/storage-idle-fd-close
Open

storage: close idle open FDs via FileManager#834
j-c-m wants to merge 1 commit into
rakshasa:masterfrom
j-c-m:feature/storage-idle-fd-close

Conversation

@j-c-m

@j-c-m j-c-m commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This helps a lot for memory usage as the OS free's associated buffers/pages wired to the idle files that used to remain open until max files eviction.

Feature closes idle file FDs after a configurable amount of time rather than leaving them open until eviction presure. Default 60s, 0 disables.

rtorrent:

rakshasa/rtorrent#1888

Feature closes idle file FDs after a configurable amount of time rather
than leaving them open until eviction presure. Default 60s, 0 disables.
@rakshasa

Copy link
Copy Markdown
Owner

This code is rather old, so I don't exactly remember how it works, but we're already evicting stale File entries before opening iirc.

So we shouldn't need to iterate over every single entry here. And likely this part of the code needs to be refactored.

@j-c-m

j-c-m commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

It does evict stale entries currently, if it's at the limit. This is more proactive and closes the files when they are idle.

@rakshasa

Copy link
Copy Markdown
Owner

You are manually iterating over all entries, while we should already have (or add) a sorted staleness queue for when evicting due to fd limits.

@rakshasa

Copy link
Copy Markdown
Owner

Check out the last couple of PR merges as FM now has a last activity cache used during eviction.

This PR might be a bit too aggressive in closing fds, and the cache likely solves a lot of the issues here.

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