mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:58:12 +00:00
Kernel: Implement a simpler, bigger cache for DiskBackedFS
The hashmap cache was ridiculously slow and hurt us more than it helped us. This patch replaces it with a flat memory cache that keeps up to 10'000 blocks in cache with a simple dirty bit. The syncd task will wake up periodically and call flush_writes() on all file systems, which now causes us to traverse the cache and write all dirty blocks to disk. There's a ton of room for improvement here, but this itself is already drastically better when doing repeated GCC invocations.
This commit is contained in:
parent
8f45a259fc
commit
a61f6ccc27
2 changed files with 97 additions and 74 deletions
|
@ -3,6 +3,8 @@
|
|||
#include "FileSystem.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
|
||||
class DiskCache;
|
||||
|
||||
class DiskBackedFS : public FS {
|
||||
public:
|
||||
virtual ~DiskBackedFS() override;
|
||||
|
@ -24,6 +26,8 @@ protected:
|
|||
bool write_blocks(unsigned index, unsigned count, const ByteBuffer&);
|
||||
|
||||
private:
|
||||
DiskCache& cache() const;
|
||||
|
||||
NonnullRefPtr<DiskDevice> m_device;
|
||||
HashMap<unsigned, ByteBuffer> m_write_cache;
|
||||
mutable OwnPtr<DiskCache> m_cache;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue