Remix.run Logo
betaby 2 days ago

Very theoretical question. If there was a usable microkernel, how hard would be it be to have an FS as a service? Are MacOS FS' processes or are they 'monolithic'?

koverstreet a day ago | parent | next [-]

I think this would be the most usable microkernel these days, and yes, it does FS as a service: https://www.redox-os.org/

There's no inherent reason why a filesystem in userspace has to have a measurable performance impact over in-kernel, done right. It would be a lot of engineering work, though.

Context switches aren't that expensive when you're staying on the same core, it's IPIs (waking up a thread on another CPU) that's inherently expensive; and you need zero copy to/from the pagecache, which is tricky. But it totally could be done.

xenadu02 a day ago | parent | prev | next [-]

So FSKit is public API and supports userspace filesystems but on macOS most built-in filesystems are kernel modules. On iOS everything except APFS is userspace.

Modern Darwin is mostly a monolithic kernel, though more and more things are moving to userspace where possible (eg DriverKit).

One interesting side-effect of various spectre mitigations is silicon improving the performance of context switches. That has the side-effect of decreasing the cost of kernel/userspace transitions. It isn't nearly as expensive as people still believe - though it isn't free either.

yjftsjthsd-h 2 days ago | parent | prev [-]

If there was a usable microkernel, then its filesystems would almost certainly be implemented in userspace; that's kinda the point of a microkernel. I can't speak to how Darwin does things, but I will point out that Linux and the BSDs have filesystems as userspace processes courtesy of FUSE; in their architecture that has a performance hit (caused by the context switching needed, I believe recently improved by use of io_uring), but it is a worked example of what you want.

betaby 2 days ago | parent [-]

I'm aware of FUSE and used NTFS driver though it back then. So we should expect similar performance with microkernels?

yjftsjthsd-h 2 days ago | parent [-]

It depends:) Old microkernels infamously did have awful perf because they took that context switch hit on everything, not just filesystems. I am told, though, that that was solved a long time ago and modern microkernels have fairly good performance. I'm not a kernel dev, though; you'll have to do your own research to get details.