Re:Freqfs: In-memory filesystem cache for Rust
by spullara on Saturday October 02, 2021 @04:14AM
(#28726950)
This is called mmap?
Re:Freqfs: In-memory filesystem cache for Rust
by haydnv on Saturday October 02, 2021 @09:51AM
(#28728566)
mmap does map file contents into memory but does not provide read-write locking. The main limitation is that a file is not necessarily the same thing as the Rust data structure that it encodes. For example, if you store a Rust Vec in a file, loading the file with mmap won't allow you to `push` a new item onto the Vec.
The major advantage of freqfs over just letting the OS handle file caching is that with freqfs you can read and mutate the data that your file represents purely in memory. For example, if you implement a BTree node as a struct, you can just borrow the struct mutably and update it, and it will only be synchronized with the filesystem in the event that it's evicted (or you explicitly call `sync`). This avoids a lot of (de)serialization overhead and defensive coding against an out-of-memory error.
Again, I will update the documentation to clarify.