247 points · by todsacerdoti · 6y ago · 180 comments
A modern DB needs efficient interaction with the OS of course, but I'd say based on experience at many companies a bigger challenge than raw efficiency is the ability to implement changes in the db itself. I've worked on 4 or 5 major databases and we can always identify many ways to improve execution, plan selection, various aspects of the db, it's just the giant challenge to alter a big code base that blocks improvements more than OS layers. Improving plan choice can make queries thousands of times faster - but you have to be able to implement it.
Back in the 90s it was common for databases to implement their own file systems or memory management
Informix in the mid/late 1980s initially had Shared Memory implementations in UNIX platforms that supported it. Then, the Turbo/OnLine/IDS servers added the option of raw disk partition use for database spaces to avoid filesystems altogether (and do raw unbuffered I/O).Maybe not exactly what you're thinking. But somewhat in the same domain.
By domains, do they mean that as "actually in use in certain sectors in the industry" or "a prototype has shown that"?
> causing some to propose that the days of Linux's dominance may be coming to an end
Who exactly would make that claim?
So, besides performance: what actual, real-life problems does this solve? I think there is some overlap with containers, and at this point, replacing them will require something a lot better.
Well, don't go jumping to "besides performance". Dennard scaling is dead, and the things that can interrupt your program in a full preemptive kernel system are myriad.
Furthermore, even if your application properly manages and produces backpressure, the OS can introduce buffering where you don't want it, often by necessity (to avoid massive context switch costs). Now, if you just want to manage backpressure over the network, an application-hosted networking stack is probably a fine solution, but if you want to accurately translate disk backpressure to network backpressure it gets more complicated.
There are heaps and heaps of ordinary programs written for preemptive systems that would see noticeable, tangible benefits to users if they were run instead on unikernels; but the main thing halting adoption is the inconvenience of adapting programs. I tried getting Capstan/OSv to work the other day and the documentation dragged me through several apparently-outdated methods of achieving the same thing, all of which failed in incomprehensible ways. Tooling for these things could use a lot of work.
This is all nice and good, but the Unikernel guys claim since 20 years its the next big revolutionary thing. In the real world, the evolutionary approach using containers has turned out to solve the problems most people care about.
Don’t get me wrong, this is fascinating stuff. But there is a difference between „changes mainstream computing“ and „cool tech to shave off another millisecond of latency“.
The other thing that people will look at is doing something like alpine && a heavy-handed seccomp/apparmor but then you're not really doing any cuts at all.
Now, of course, applications themselves can fail at this too. Look at Postgres, maybe, where typically people rely on [AUTO]VACUUM, but if your application runs continuously, then there is no right time to run it.
Didn't you hear? Some.
Most attacks aim at executing arbitrary code in the process space of the application being targeted. The lack of user-land does not help.
Will Serverless End the Dominance of Linux in the Cloud? https://dl.acm.org/doi/pdf/10.1145/3102980.3103008
That appears to come from the FAQ on Github for "rumprun" dated 2015.
Rump kernels were introduced in NetBSD in 2009. It was an described then as an acronym for runnable userspace meta programs.
https://blog.netbsd.org/tnf/entry/runnable_userspace_meta_pr...
I have not used rumprun for Linux but I still use the rump utilities included with NetBSD.
What do you think about WASM in the kernel with the same high level concept with Unikernel? link in the below
https://destroyallsoftware.com/talks/the-birth-and-death-of-...
Until those are dealt with wasm will never move past it's current status quo - malware in the browser.
Is there really a support layer for Emacs in the kernel?
Now the real question. You are statically linking against a modified glibc, so they make calls to your kernel library instead to the system call and you can do some nice optimizations along the way. Which I think make sense.
I can see this is cool for things that directly interface to glibc, but do you think this is viable for applications using multiple layers between the kernel and the application?
We have only run C applications so far, so I'm unsure how it will all work for servers written in other programming languages. I think applications which rely on complex multi-process middleware (like Java JBoss, etc) will be hard or even impossible to port.
Because of that, I think “without a clear answer at the moment” is worrisome. Are there partial answers to these questions?
Hm, isn’t reboot just slightly more complicated than restarting your application? And most of the today’s apps would still require “rebooting” be it a container or a virtual machine
Not saying it is easy but at the end of the day it's just engineering work.
This can lead to some rather spectacular performance benefits. One thing is that you remove the syscall overhead, but more importantly you can do a lot more optimizations at the compiler/linking steps.
You can remove complex code that tries to dynamically model the world with rather plain code that does just what it is supposed to. With IncludeOS (C++17 unikernel) we did make a firewall implementation that instead of using complex data structures relied on preprocessing the rule set and translate it into C++ code. The code to do this was quite simple and resulted in pretty amazing figures wrt number of rules per packet per second. Metaprogramming can sometimes deliver amazing results.
Similar things can be done in a traditional kernel as well and we've seen eBPF firewall implementations that are able to get similar numbers. On the flip side eBPF and it's firewall implementation is order of magnitude more complex. However, you can push eBPF code onto the networking card which can be a huge benefit. And ofc you could make a kernel module that implements a specific firewall ruleset and get similar performance without eBPF.
I like unikernels because I feel I can understand them better. You can reason about them and they are easier to optimize for very specific workloads.
So why aren't we using them? Likely because we know Linux so well and we've invested a lot in it. It runs everywhere and is extremely well supported. Bringing a new operating system to market is challenging, bringing a new operating system with a entirely different architecture is even harder. Even if it, on a purely technical level, could yield better results.
Being actually different is one of the few things that gives someone a reason to look twice at the new system.
From Wikipedia:
“A unikernel is a specialised, single address space machine image constructed by using library operating systems. A developer selects, from a modular stack, the minimal set of libraries which correspond to the OS constructs required for their application to run. These libraries are then compiled with the application and configuration code to build sealed, fixed-purpose images (unikernels) which run directly on a hypervisor or hardware without an intervening OS such as Linux or Windows.”
Third paragraph
> The unikernel is a cloud-era handle for the classic systemstechnique of linking an application with a library of oper-ating system components (including memory management,scheduler, network stack and device drivers) into a singleflat address space, creating standalone binary image that isbootable directly on (virtual) hardware [22]. The advantageof this approach is that kernel functionality can be special-ized to fit the needs of the target application to increasethe performance of the application or to support it within ahighly restricted execution domain.
And second chapter.
Whether it's good depends on what you're doing. UKL will[1] allow you to link a regular server application to Linux and then run that single binary on baremetal or in a hypervisor, and give you a decent performance boost over running the application on top of a normal kernel. How much of a performance boost depends a great deal on the program, almost everything will be a few percent faster, and some applications a lot more.
[1] I'm using the future tense here because although we do run real programs with it today there's still a bunch of development work to do before it works smoothly. The code is: https://github.com/unikernelLinux
Instead of installing an OS and installing your app on that OS, the OS is a library you use to talk to the hardware.
It's good for two reasons.
First security, if you only use the HDD and network, you don't have to include code for display or mouse etc. which could be a security risk.
Second, it's faster, because you don't have to do syscalls, since your app IS the OS, syscalls don't need to get out of userspace.
[0] https://www.nccgroup.trust/globalassets/our-research/us/whit... , from https://news.ycombinator.com/item?id=19738905
https://nanovms.com/dev/tutorials/assessing-unikernel-securi...
It makes good sense to compare unikernels against conventional GNU/Linux. It's the standard configuration, and it sets the bar. Describing this as a pyschological hump isn't a sensible response.
I don't know what advances to things like the networking stack is meant to refer to. The article should be clear and explicit about what part of the paper this is responding to. As it stands it looks like a straw-man.
The response to unikernels are un-debuggable makes little sense. Someone can work on a debugger while claiming the current state of debugging is poor. No contradiction there.
Downplaying the significance of Data Execution Prevention isn't a convincing defence. Downplaying the significance of ASLR isn't a convincing defence. These are valuable security measures.
This excerpt from the conclusion seems to indicate a reluctance to take security concerns seriously at all, as if a security analysis is an emotional attack: there's a thousand little kids out there wanting to crap on anything they can. Security bugs are bugs at the end of the day and all one has to do is look at any random popular github to understand how many bugs we as humans create.
Edit: Thanks for the updated link. UKL can be compiled with usual hardening features like ASLR, stack hardening, RELRO.
As I said here (https://news.ycombinator.com/item?id=23202042) I'm dubious about the security story around unikernels, but most of the issues in this paper are not relevant to UKL specifically.
Mirror: https://web.archive.org/web/20200311095425/https://www.nccgr...
On the face of it, multiprocess support might seem a bit stupid, but it would greatly help the porting of more complex applications. The 'processes' wouldn't need virtual address space or memory protection, just give them a block of memory and pick a CPU to run the code.
If you have multithreading, do you need any scheduling code, or can you just pick a CPU for each thread and leave them to run? What about the kernel's own threads & processes?
That's interesting, how does Linux implement it's kernel threads without any scheduling code?
Actually achieving this is tricky: At the moment you need to use special compiler flags and a completely different link line from normal. Then there's the issue of how/whether the library Linux is configured generically or you somehow allow people to set CONFIG_* options.
Solutions based on Netbsd's rumpkernels exist. There's nothing about unikernels that says Linux.
Performance benefits: In truth we're still measuring this, there is a very smart student at BU who is investigating this and coming up with results for a forthcoming paper which I don't want to preempt too much. Almost all applications should see a small benefit, say of the order of 5%, but it's hoped that some will see a much larger benefit, and that it should be possible to make modest modifications in order to enjoy large benefits (perhaps only compiler and linker flags and such like).
These are very much hopes rather than firm promises at the moment.
getpid exists and returns a number - in fact it can return any number you like :-) Everything is linked into a single vmlinux which runs in a single address space. (As an aside I'll have to remember to ask Ali if he's thought about what number getpid() should return in UKL - I guess returning 1 would cause least surprise)
> Can I fork or create threads?
Fork no, threads yes. Threads are implemented using kernel threads.
> Can I directly access kernel's internal APIs like a kernel module?
Yes, although whether this is a good idea is another matter. Note that it's still Linux so internal APIs are unstable and can go away or change their meaning at any time, so if your application starts to rely on internal APIs you could quickly get into trouble.
Free software is great, but not everyone is in the position where they can release all of their code all the time.
For a unikernel to be viable it can't have copyleft code in it.
But that is all. It works exactly like copyright in that regard. To be subject to it you need to have received a copy of program.
So no, running the program in the cloud is not distribution.
(Of course I work for Red Hat and the cult thinks all code should be free :-)
No. That's formally wrong, and it doesn't imply what you think it implies.
Using copyleft code means that if you distribute the resulting binary, you also have to distribute the corresponding source code. If you can't do that, you can't distribute the binary.
Is that a problem? No. You distribute object files and libraries, accompany the copylefted libraries with their source code, and let the end user link them together statically. Problem solved. Arguably, that's how all software installation on Unix should work; it solves so many other problems, too.
IIRC you can write proprietary kernel modules, which are loaded at runtime.
> Why can't you link user code with kernel? User code usually depends on POSIX interface and Linux is just one of the implementations.
Because the kernel is licensed under GPLv2. If you statically link to the kernel, then all interpretations of the GPL are that your work is a derivation and must be GPL'd (at least assuming it is "distributed").
>NOTE! This copyright does not cover user programs that use kernel services by normal system calls - this is merely considered normal use of the kernel, and does not fall under the heading of "derived work".
(even without actual syscall, you can consider unikernels as normal use of kernel)
Unikernels are viable even if they don't allow you to do that, for many reasons - performance, workload isolation, ease of installation.
Linux is licensed under GPL-2.0 WITH Linux-syscall-note.
>NOTE! This copyright does not cover user programs that use kernel services by normal system calls - this is merely considered normal use of the kernel, and does not fall under the heading of "derived work".
More generally can link LGPL code statically without making resulting binary subject to copyleft or releasing the source code. Increasing number of programmers don't know what object file is anymore (they didn't learn to program in C/C++) and this causes endless confusion.
https://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynami...
> For the purpose of complying with the LGPL (any extant version: v2, v2.1 or v3):
> (1) If you statically link against an LGPLed library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application.
GP provided a clear scenario in which their warning is categorically true.
> Linux is licensed under GPL-2.0 WITH Linux-syscall-note.
The note clarifies that syscalls are interpreted as a form of dynamic linking, which would be quite obvious in retrospect given you can run unmodified linux software on non-linux kernels (https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux).
> More generally can link LGPL
You do realise the LGPL and the GPL are different licenses with different requirements and constraints right? And the linux kernel is not licensed under the LGPL? And that what you quote specifically notes that even under the LGPL, static linking results in a derived work?
No. You can provide object files without source code and it does not become covered work. This is for example how using LGPL in Qt works.
For example, could it be used for a softsynth which takes in midi input and emits digital audio with the OS only contributing guaranteed sub-millisecond latency?
10 milliseconds is often considered the threshold of human perception with regards to audio latency. (It's possible that it's lower under some circumstances, but 10 ms is a good enough approximation for my purposes.) My goal is to create a sound/music tool which runs lots of DSP and which has a total system latency of under 10 milliseconds, including OS, application (including intrinsic latency of DSP procedures), hardware, and sound in air (about 1 ms per 3 meters).
When I read about latency, I often see "we're at 6-9 ms, that's good enough because it's not perceptible". Unfortunately, that's not good enough if there are several components which contribute to total system latency and they are all pushing 10 ms. Hence, my sub-ms requirement for the OS.
Committing to a platform will be a costly choice. I don't want to invest in writing for realtime Linux only to find that I really need to run a hardcore RTOS, or run dedicated DSP chips, etc.
That's why I'm interested in whether running a unikernel can offer stronger guarantees.
While your goal is admirable - it certainly is possible to come up with scenarios where "sub-ms" latency is desirable - it's really not relevant.
Your stated goal ("...lots of DSP ... under 10 msec") is already entirely achievable on Linux, assuming you're close enough to your speakers (or wearing headphones).
But sub-msec can only make sense here if it describes scheduler latency, since there's no audio hardware that can function in the sub-msec range. The linux scheduler is way, way below that threshold and SCHED_FIFO threads will see that performance barring hardware issues (c.f. https://manual.ardour.org/setting-up-your-system/the-right-c...)
Finally .... writing audio software is a lot of fun. But please don't just jump in without seeing if you can instead contribute to an existing project first. The field is littered with the dead and half-dead corpses representing the discarded work of developers who thought it would be fun, and then moved on.
researchgate is much much nicer, and gives a lot of info: citations, related papers, you could go see info about authors, ask questions, see what project this paper is on. Researchgate allows discovering interesting papers in a seamless maner.
Yet again the ACM showing how out-of-touch it can be with its members and patrons.
Wouldn't people say ACM are out of touch if they don't adopt all the common junk you see on websites? Their website is so out of date it doesn't have a cookie banner! Best I get my information from somewhere that keeps up with the times ... and the law!
Stripping down traditional kernels to work as unikernels is not a new thing: https://github.com/rumpkernel/rumprun
MirageOS was initially clearly designed to run on top of an hypervisor. The idea was going from host os, guest os and application to just host os and unikernel.
As I see it, it was a different way of solving the same problem containers are now used for : do you really need both a host os and guest os when all you want is isolation ? Using container is pushing isolation in the kernel while losing the actual virtualization (in a way merging host os and guest os) while unikernel is pushing the useful part of the guest os into the application (merging guest os and application) keeping the benefits of full virtualization. I think it's why Docker bought the company making MirageOS.
I don't really see where rump kernels sit there. Clearly there is interest as people are working on them but I fail to see where they would be useful.
The makers of top-performing NICs have been quite good at providing direct user-space access to their hardware, typically by exposing a ring buffer in shared memory, and maybe mapping device registers too, so that the process on the isolated core never does another system call until shutdown weeks later.
It is some hassle to get customers to add boot flags (isolcpus=, nohz_full, rcu_nocbs=, rcu_nocb_poll, hugepages=, etc.), and to put any mapped files in /dev/shm or /dev/hugepages so the kernel won't invent excuses to block the procees, and to direct irqs to other cores; but unikernel setup is probably not simpler.
So, I'm not sure what a unikernel would get me. Portability, or independence from proprietary drivers?
http://bitcharmer.blogspot.com/2020/05/t_84.html
I'm not an expert on unikernels but my assumption is that you will see none of that OS jitter.
You still have cores to isolate, busybody kernel threads to suppress, and hardware interrupts to direct elsewhere, but TLB shootdown paranoia is largely a product of the current fashion favoring multi-threading over running separate processes with carefully chosen sharing.
Demo with virtio-gpu support: https://twitter.com/eliasnaur/status/1249765031299952646
"We use cookies to ensure that we give you the best experience on our website.
It seems your browser doesn't support them and this affects the site functionality."
Unikernels run exactly one application, but can be based on an arbitrarily complicated OS (specialised) to that one application. Exokernels can run arbitrarily many applications, but OS functionality is minimal and limited to ensuring protection and multiplexing of resources.
Specialising a rich OS (such as Linux) to a single application might yield OS functions that are as restricted as those you find in an exokernel.
However, the tooling is changing.
We have memcached compiled for UKL but for some reason Ali has made that repo private (it's under the same namespace as above). I will ask him if he can make the other repos public this week.
http://sci-hub.tw/10.1145/3317550.3321445
Maybe link the top-level post there?