Live data from Hacker News

Unikernels: The Next Stage of Linux’s Dominance (2019)

dl.acm.org

21–30 of 187 posts

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#22
post #2

I'm one of the authors on this paper, so ask away if you have questions.

What is a unikernel and why it's good?

Basically you replace the system calls into the kernel with library calls. So you end up with a single binary that contains both the application as well as the operating system functionality.

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.

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#23
post #12

Unikernels are typically statically linked. Using copyleft code means the whole resulting binary is subject to copyleft. 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.

Well yes, if you want to distribute binaries to people and keep the source private (like in 90's), copyleft unikernels isn't the way to do that.

Unikernels are viable even if they don't allow you to do that, for many reasons - performance, workload isolation, ease of installation.

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#24
post #9

Earlier quoted context omitted.

(Not the author) No, the paper describes a small patch to Linux (~20 lines) + modifications to glibc that enable using Linux as a unikernel. Their goal is to have the modifications upstreamed so that Unikernel linux could be a GCC target etc.

I also don't get it. "Linux as a unikernel" does not make sense. The entire point of a unikernel is to not have the OS in every container/VM.

If you statically link your software with the kernel, presumably an optimizing compiler will be able to remove most of the kernel from the resulting binary.

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#25
post #12

Unikernels are typically statically linked. Using copyleft code means the whole resulting binary is subject to copyleft. 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 not everyone is in the position where they can release all of their code all the time.

you lost your repository credentials? What prevent you from releasing code "all the time"?

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#26
When I make a system where a unikernel could do the job, I usually want a full OS for program setup and initialization, and then an isolated core for the main loop, sharing (single-writer) memory pages with other, less performance-critical processes for logging, stats reporting, and any needed file system activities.

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?

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#27
Full disclosure: I have only briefly fiddled with unikernels. And in all honesty, I think there could be a good real life application for them. But the biggest problems I see is that even though they have been around for a while, building them is still incredibly complex and time consuming and there isn't a core community behind them and looking at it, it seems like they are starting to suffer from the javascript syndrome - hundreds of single maintainer or micro-communities doing their own thing and putting a sticker("unikernel" in this case) on top. As I said I haven't paid a whole lot of attention to them and I'm hoping someone is addressing these issues.

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#28
post #9

Earlier quoted context omitted.

(Not the author) No, the paper describes a small patch to Linux (~20 lines) + modifications to glibc that enable using Linux as a unikernel. Their goal is to have the modifications upstreamed so that Unikernel linux could be a GCC target etc.

I also don't get it. "Linux as a unikernel" does not make sense. The entire point of a unikernel is to not have the OS in every container/VM.

The crucial part of the paper is that they:

• Added a new kernel configuration option to allow theuser to select if he/she wants to compile the Linux kernel as UKL.

• Added a call to an undefined symbol (protected by an #ifdef) that can be used to invoke application code rather than creating the first userspace process.

• Created a small UKL library which has stubs for syscalls. These stubs hide the details of invoking the required kernel functionality now that the regular interface (i.e.,the syscall instruction) is no longer used.

• Changed glibc so that instead of making syscalls into the kernel, it makes function calls into UKL library.

• Changed the kernel linker script to define new segments such as thread local storage (TLS) segments which are present in application ELF binaries.

• Added a small amount of initialization code before invoking the application to replace initialization normally done by user level code, e.g., for network inter-face initialization.

• Modified the kernel linking stage to include the application code, glibc and UKL library to create a single binary.

Basically, I think the idea is you get all the linux syscalls (+ filesystems... + network stack... + hardware support... + everything) for 'free'. Sure you'll have a pretty large binary, but you won't have to write anything.

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#29
post #12

Unikernels are typically statically linked. Using copyleft code means the whole resulting binary is subject to copyleft. 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 not everyone is in the position where they can release all of their code all the time. you lost your repository credentials? What prevent you from releasing code "all the time"?

Very often corporate wants to keep the application code private.

Re: Unikernels: The Next Stage of Linux’s Dominance (2019)

#30
post #7

Earlier quoted context omitted.

https://en.wikipedia.org/wiki/Unikernel 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 pe…

As I've always understood it, it's not just performance but also security: there's a lot less code running with your code which cuts the surface area for bugs and thus security holes.

> there's a lot less code running with your code

Tell me if I am wrong, but is it always true though? Unikernel libraries definitely are largely not as proven as Linux kernel. Then how is unikernel secure than Linux system call?

Post reply on HN