News for hackers. Stuff that matters.
Re:Writing a file system from scratch in Rust by ravenstine on Monday July 27, 2020 @05:24PM (#23969553)
Is there any advantage in writing a custom file system for a niche purpose? It seems like most file systems are just different variations of managing where/when files are written simultaneously. Could a file system written specifically for something like PostgreSQL cut out the middle-man and increase performance?
Re:Writing a file system from scratch in Rust by topspin on Monday July 27, 2020 @05:32PM (#23969640)
Yes. Oracle has done this (ASM) to eliminate overhead, implement fault tolerance and provide a storage management interface based on SQL, for example.

I once made a 'file system' to mount cpio archives (read-only) in an embedded system. Cpio is an extremely simple format to generate and edit (in code) and mounting it directly was very effective.

Re:Writing a file system from scratch in Rust by formerly_proven on Monday July 27, 2020 @05:37PM (#23969682)
I suspect operating on block storage directly may both be easier and more reliable for databases, since about 75 % of the complication in writing transactional I/O software is working around the kernel's behavior.
Re:Writing a file system from scratch in Rust by zzz61831 on Monday July 27, 2020 @06:21PM (#23970106)
Kernel's fsyncing behavior is one thing, but just relying on a massive amount of fragile C code running in kernel is a significant liability, especially if your software is a centralized database and crashes, panics will bring down everything.
Re:Writing a file system from scratch in Rust by formerly_proven on Monday July 27, 2020 @06:25PM (#23970136)
Yes, and also the traditional answer was that the kernel handles weird and complicated hardware and can talk to RAID controllers properly, but nowadays hardware has much less variance, and RAID is rare (and arguably unnecessary for a direct-IO database).

I think it'd be viable for an enterprise-y database to do IO directly over NVMe. Imagine the efficiency and throughput gains you could get from a database that (1) has a unified view of memory allocation in the system (2) directly performs its page-level IO on the storage devices.

Re:Writing a file system from scratch in Rust by anitil on Tuesday July 28, 2020 @12:50AM (#23972388)
Wow this comment just made me fall down a rabbit hole. I've only just surfaced. The Kaitai project actually comes with some pre-defined bindings for cpio which meant I was up and running very quickly.

https://formats.kaitai.io/cpio_old_le/index.html

Re:Writing a file system from scratch in Rust by topspin on Tuesday July 28, 2020 @12:50PM (#23977768)
Yes, cpio is ancient and simple and very easy to work with. The Kaitai project didn't exist at the time; I used the C structs documented in man pages.
Re:Writing a file system from scratch in Rust by tene on Monday July 27, 2020 @05:28PM (#23969589)
You may be interested in a paper written by the Ceph team: "File Systems Unfit as Distributed Storage Backends: Lessons from 10 Years of Ceph Evolution"

https://www.pdl.cmu.edu/PDL-FTP/Storage/ceph-exp-sosp19.pdf

There are definitely some significant benefits you can get from managing your own storage, rather than using a filesystem.

Re:Writing a file system from scratch in Rust by jandrewrogers on Monday July 27, 2020 @07:12PM (#23970488)
Yes, this is common in database engines. Doing so allows you to optimize the file system along a very different set of performance tradeoffs and assumptions than a typical generic file system. Beyond that, it also gives you direct control of file system behavior, the lack of which is a source of code complexity and edge cases. This is not transparent to the database, something like PostgreSQL would need to have its storage layer redesigned to explicitly take advantage of the guarantees.

It isn't just about performance gains, which are substantial, it also greatly simplifies the design and code by eliminating edge cases, undesirable behaviors, and variability in behavior across different deployment environments.