3 ms·
One advantage is consistency across host platforms, but the main advantage is that the file data can be accessed (and mutated) in memory in a deserialized forma
by haydnv 5y ago
One advantage is consistency across host platforms, but the main advantage is that the file data can be accessed (and mutated) in memory in a deserialized format. If you let the OS take care of it, you would still have the overhead of serializing & deserializing a file every time it's accessed.
- dfranke 5y agoThat's what mmap is for.
- deleted 5y ago[deleted]
- haydnv 5y agoIt might be possible to replace freqfs with mmap on a POSIX OS, but a) you would still have to implement your own read-write lock, and b) you would (I think probably?) lose some consistency in behavior across different host operating systems.
- gpderetta 5y agommaps for read, explicit API for writing, a-la LMDB. Buggy readers can read inconsistent data but cannot corrupt the os.
- vlovich123 5y agoWhich OSes does this run on that doesn’t have some kind of mmap operation?
- alexruf 5y agoPersonally I don’t see a scenario for myself, but I can imagine that there are some where this might be useful. But isn’t there a extremely high risk of data loss an inconsistency when adding an extra layer on top of OS file system handling?
- haydnv 5y agoIf there is any concurrent access to cached files not through freqfs, there is a risk of inconsistency and crashes.
- ericbarrett 5y agoFreqfs seems like a shim you'd add to an existing project for a quick optimization. Whereas mmap et al. are "better" the same way any specific, built-to-purpose code will be "better" than just bolting a framework on. Sometimes it's the right call to do the extra work; sometimes it's 100% more effort (both development and maintenance) for an extra 10% gain.