mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 09:18:52 +00:00
Ext2FS: Uncache unused Inodes after flushing contents to disk
Don't keep Inodes around in memory forever after we've interacted with them once. This is a slight performance pessimization when accessing the same file repeatedly, but closing it for a while in between. Longer term we should find a way to keep a limited number of unused Inodes cached, whichever ones we think are likely to be used again.
This commit is contained in:
parent
19398cd7d5
commit
c538648465
Notes:
sideshowbarker
2024-07-19 11:25:57 +09:00
Author: https://github.com/awesomekling
Commit: c538648465
1 changed files with 14 additions and 0 deletions
|
@ -503,7 +503,21 @@ void Ext2FS::flush_writes()
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
DiskBackedFS::flush_writes();
|
||||
|
||||
// Uncache Inodes that are only kept alive by the index-to-inode lookup cache.
|
||||
// FIXME: It would be better to keep a capped number of Inodes around.
|
||||
// The problem is that they are quite heavy objects, and use a lot of heap memory
|
||||
// for their (child name lookup) and (block list) caches.
|
||||
Vector<InodeIndex> unused_inodes;
|
||||
for (auto& it : m_inode_cache) {
|
||||
if (it.value->ref_count() != 1)
|
||||
continue;
|
||||
unused_inodes.append(it.key);
|
||||
}
|
||||
for (auto index : unused_inodes)
|
||||
uncache_inode(index);
|
||||
}
|
||||
|
||||
Ext2FSInode::Ext2FSInode(Ext2FS& fs, unsigned index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue