Live data from Hacker News

We replaced Firecracker with QEMU

hocus.dev

71–80 of 156 posts

Re: We replaced Firecracker with QEMU

#71

I really want VM's to integrate 'smarter' with the host. For example, if I'm running 5 VM's, there is a good chance that many of the pages are identical. Not only do I want those pages to be deduplicated, but I want them to be zero-copy (ie. not deduplicated after-the-fact by some daemon). To do that, the guest block cache needs to be integrated with the host block-cache, so that whenever some guest application tries…

https://www.kernel.org/doc/html/latest/admin-guide/mm/ksm.ht...

zero-copy is harder as one system upgrade on one of them will trash it, but KSM is overall pretty effective at saving some memory on similar VMs

Re: We replaced Firecracker with QEMU

#72

Earlier quoted context omitted.

yeah I was reading so I could find out what they did. I understand that they need to sell their product but jeez. don't leave us hanging like that

I didn't want to go into all the technical details, but we have another write-up that goes into details about RAM management: https://github.com/hocus-dev/hocus/blob/main/rfd/0003-worksp... Other than making sure we release unused memory to the host, we didn't customize QEMU that much. Although we do have a cool layered storage solution - basically a faster alternative to QCOW2 that's also VMM independent. It's calle…

> I didn't want to go into all the technical details

HN is here for the technical details ;)

Re: We replaced Firecracker with QEMU

#73
post #13

Earlier quoted context omitted.

KVM has KSM (kernel samepage merging) since a long time ago that de-duplicates pages.

But that makes a copy first, and only later notices that the pages are the same and merges them again. Better to not make copies in the first place.

it's not really possible in hypervisor as it doesn't know what guest will be putting in its memory beforehand

Re: We replaced Firecracker with QEMU

#74
post #40

"Firecracker's RAM footprint starts low, but once a workload inside allocates RAM, Firecracker will never return it to the host system." Firecracker has a balloon device you can inflate (ie: acquire as much memory inside the VM as possible) and then deflate... returning the memory to the host. You can do this while the VM is running. https://github.com/firecracker-microvm/firecracker/blob/main...

The first footnote says If you squint hard enough, you'll find that Firecracker does support dynamic memory management with a technique called ballooning. However, in practice, it's not usable. To reclaim memory, you need to make sure that the guest OS isn't using it, which, for a general-purpose workload, is nearly impossible

> which, for a general-purpose workload, is nearly impossible

That depends on the workload and the maximum memory allocated to the guest OS.

A lot of workloads rely on the OS cache/buffers to manage IO so unless RAM is quite restricted you can call in to release that pretty easily prior to having the balloon driver do its thing. In fact I'd not be surprised to be told the balloon process does this automatically itself.

If the workload does its own IO management and memory allocation (something like SQL Server which will eat what RAM it can and does its own IO cacheing) or the VM's memory allocation is too small for OS caching to be a significant use after the rest of the workload (you might pair memory down to the bare minimum like this for a “fairly static content” server that doesn't see much variation in memory needs and can be allowed to swap a little if things grow temporarily), then I'd believe is it more difficult. That is hardly the use case for firecracker though so if that is the sort of workload being run perhaps reassessing the tool used for the job was the right call.

Having said that my use of VMs is generally such that I can give them a good static amount of RAM for their needs and don't need to worry about dynamic allocation, so I'm far from a subject expert here.

And, isn't firecraker more geared towards short-lived VMs, quick to spin up, do a job, spin down immediately (or after only a short idle timeout if the VM might answer another request if one comes in immediately or is already queued), so you are better off cycling VMs, which is probably happening anyway, than messing around with memory balloons? Again, I'm not talking from a position of personal experience here so corrections/details welcome!

Re: We replaced Firecracker with QEMU

#76
post #3

Listen people, Firecracker is NOT A HYPERVISOR. A hypervisor runs right on the hardware. KVM is a hypervisor. Firecracker is a process that controls KVM. If you want to call firecracker (and QEMU, when used in conjunction with KVM) a VMM ("virtual machine monitor") I won't complain. But please please please, we need a word for what KVM and Xen are, and "hypervisor" is the best fit. Stop using that word for a user-lev…

Nitpick: it’s not accurate to say that a hypervisor, by definition, runs right on the hardware. Xen (as a type-1 hypervisor) has this property; KVM (as a type-2 hypervisor) does not. It’s important to remember that the single core responsibility of a hypervisor is to divide hardware resources and time between VMs, and this decision-making doesn’t require bare-metal. For those unfamiliar, the informal distinction betw…

KVM is a type-1 hypervisor [1]

[1]: https://www.redhat.com/en/topics/virtualization/what-is-KVM

Re: We replaced Firecracker with QEMU

#77
post #61

Earlier quoted context omitted.

How? KVM and Xen are kernel level. QEMU uses KVM but also has a software virtualization capability. Libvirt is an API abstraction over it all. virt-manager is a gui app to manage libvirt machines. Proxmox as well. Proxmox VE talks to VMHost via libvirt.

Libvirt does not use KVM. Libvirt uses either QEMU (which in turn might or might not use KVM) or Xen or other hypervisors. So it's incorrect to say that Libvirt abstracts over KVM. And virt-manager indeed manages Libvirt machines so it's not at the level of QEMU as you wrote in the parent comment: > Proxmox is a virtual machine manager (like QEMU, virt-manager)

Semantics, libvirt abstracts over KVM via QEMU because QEMU/KVM/HVT is all one driver.

Re: We replaced Firecracker with QEMU

#78

Earlier quoted context omitted.

But that makes a copy first, and only later notices that the pages are the same and merges them again. Better to not make copies in the first place.

How are you going to know in advance that the pages are going to be the same? e.g. your guest kernel is loading an application into memory, by reading some parts of an ELF file from disk. Presumably each VM has its own unique disk, so the hypervisor can't know that this is "the same" page of data as another VM has without actually reading it into memory first and calculating a hash or something. If the VMs share a di…

Chromium load time with an empty profile on my system is 4.5 seconds with a cleared disk block cache, and 2.0 seconds with a warm disk cache.

So startup time could be better than halved. Seems worth it.

Re: We replaced Firecracker with QEMU

#79

Earlier quoted context omitted.

I didn't want to go into all the technical details, but we have another write-up that goes into details about RAM management: https://github.com/hocus-dev/hocus/blob/main/rfd/0003-worksp... Other than making sure we release unused memory to the host, we didn't customize QEMU that much. Although we do have a cool layered storage solution - basically a faster alternative to QCOW2 that's also VMM independent. It's calle…

> I didn't want to go into all the technical details HN is here for the technical details ;)

that should be the HN motto!

Re: We replaced Firecracker with QEMU

#80

Earlier quoted context omitted.

But that makes a copy first, and only later notices that the pages are the same and merges them again. Better to not make copies in the first place.

How are you going to know in advance that the pages are going to be the same? e.g. your guest kernel is loading an application into memory, by reading some parts of an ELF file from disk. Presumably each VM has its own unique disk, so the hypervisor can't know that this is "the same" page of data as another VM has without actually reading it into memory first and calculating a hash or something. If the VMs share a di…

> pages not shareable, unless you use some sort of filesystem optimised for that.

btrfs on the host would have support for deduplication of identical pages in the disk images. It's true that a CPU-costly scan would be needed to identify new shared pages, if for example, two VM's are both updated to the latest distro release.

Post reply on HN