3 ms·
Why pay the performance price of a full kernel in your machine if you are only going to run one application? I'm not the author, but running on bare metal is m
by toast0 6y ago
Why pay the performance price of a full kernel in your machine if you are only going to run one application?
I'm not the author, but running on bare metal is more fun than running in a hypervisor. And removing layers from your stack lets you see what the cost and value of the layers are. I've only done bootstrapping on x86 and 8-bit processors (which is just set your reset vector), but x86 has a lot of isoterric setup stuff, and learning about the magic is interesting, if not totally useful.
Also, some runtime environments have a lot of manageability within; probably less than an OS, but maybe enough. Not sure about Go.
- vbezhenar 6y agoOne reason to avoid bare metal is drivers. There is a lot of hardware around. New hardware is released every day. And you need to write and maintain drivers for that hardware. That's a tremendous effort and hardware manufacturers usually write drivers for a very few operating systems and Go unikernel certainly won't be one of them. Using virtualization provides a simple common layer, so host operating system can deal with drivers and guest operating system can deal with more interesting things.
- toast0 6y agoOf course you'll need to write a OS specific driver for critical hardware like interrupt controllers and system timers, but drivers for other things like network cards and disk controllers can be reused if you adopt the other OS's interfaces. Things like ndiswrapper exist to use windows drivers on Linux or FreeBSD; Linux, FreeBSD, and NetBSD also have a large pool of drivers, which can be used depending on which system's driver model you like best.
- voltagex_ 6y agoLet's say I grabbed the e1000 driver from Linux, how much of the Linux kernel would I end up re-writing (badly)?
- Koshkin 6y agoWhy not just grab some other parts of Linux? Or, better yet, link your application right into it?
- toast0 6y agoI haven't done it, and the e1000 driver is pretty big, so it's hard to scan quickly, but the general shape is you'd need to support the kernel functions the driver calls, and setup compatible kernel structures for the driver. At least the parts of the driver you call. Things like kernel malloc to setup pages and what not, mapping the device address, allocating interrupts, DMA (maybe), PCI, logging, maybe locking, basic c library stuff (memcpy etc). Some of those, you can probably just stub out, but some if it you have to do (badly or not). Some of that you probably need or want to build anyway. It's a fair bit of work, but if you want to support a lot of hardware, it's probably less work than porting a bunch of drivers.
- voltagex_ 6y agoThe e1000 came to mind because it's a commonly emulated network card. I wonder now what is more common in real servers.
- toast0 6y agoe1000 is pretty common in servers, too. It's got a lot of variations though, which makes the full driver pretty big. virtio-net is a lot easier to write a driver for, of course. :)
- truncate 6y agoHow much benefit would it be over stripping an existing kernel, e.g. Linux/BSD, remove all modules that you don't need, tune schedulers for one application etc?
- toast0 6y agoHard to say, you'd really need to do both well to compare. Depending on the unikernel design though, you can significantly reduce user/kernel context switches beyond what you can with a tuned general purpose OS, potentially to the point of always sitting in ring 0. How much difference that makes, of course depends on your application and the quality of your various kernels.