[VictoriaFallS] Cache the results of reading inodes.

This reduces the number of reads when starting up the OS by ~30% (32-23
for a basic use case).

In the future we should cache things using a BTree in the VFS but this
is sufficient for now.
This commit is contained in:
Drew Galbraith 2024-01-11 18:29:51 -08:00
parent e7cc98a20c
commit 7b8528ea99
2 changed files with 14 additions and 5 deletions

View file

@ -1,5 +1,6 @@
#pragma once
#include <glacier/container/hash_map.h>
#include <glacier/memory/move.h>
#include <glacier/memory/unique_ptr.h>
#include <yellowstone/yellowstone.yunq.h>
@ -24,10 +25,12 @@ class Ext2Driver {
private:
glcr::SharedPtr<Ext2BlockReader> ext2_reader_;
glcr::UniquePtr<InodeTable> inode_table_;
glcr::HashMap<uint64_t, mmth::OwnedMemoryRegion> inode_cache_;
Ext2Driver(const glcr::SharedPtr<Ext2BlockReader>& reader,
glcr::UniquePtr<InodeTable> inode_table)
: ext2_reader_(reader), inode_table_(glcr::Move(inode_table)) {}
glcr::ErrorOr<mmth::OwnedMemoryRegion> ReadInode(Inode* inode);
glcr::ErrorOr<mmth::OwnedMemoryRegion> ReadInode(uint64_t inode_num,
Inode* inode);
};