Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Hot-plug vCPUs #2609

Open
3 tasks done
jeromegn opened this issue Jun 3, 2021 · 6 comments
Open
3 tasks done

[Feature Request] Hot-plug vCPUs #2609

jeromegn opened this issue Jun 3, 2021 · 6 comments
Labels
Priority: Low Indicates that an issue or pull request should be resolved behind issues or pull requests labelled ` Roadmap: New Request Status: Parked Indicates that an issues or pull request will be revisited later

Comments

@jeromegn
Copy link
Contributor

jeromegn commented Jun 3, 2021

Feature Request

We'd like to be able to add (and remove) vCPUs from running firecracker microvms. It appears to be possible to do that with KVM. Examples I've seen define how many vCPUs at most a VM might use and then the actual number it will be using at boot. Then you can add vCPUs via virsh.

https://www.unixarena.com/2015/12/linux-kvm-how-to-add-remove-vcpu-to-guest-on-fly.html/

This would allow use to add a "burst" feature when CPU usage spikes.

Describe the desired solution

An API to modify a running microvm's vCPUs count.

This should notify the guest VM of the change:

Dec 16 12:48:28 UA-KVM1 kernel: CPU1 has been hot-added
Dec 16 12:48:28 UA-KVM1 kernel: SMP alternatives: switching to SMP code
Dec 16 12:48:57 UA-KVM1 kernel: smpboot: Booting Node 0 Processor 1 APIC 0x1
Dec 16 12:48:57 UA-KVM1 kernel: kvm-clock: cpu 1, msr 0:3ff87041, secondary cpu clock
Dec 16 12:48:57 UA-KVM1 kernel: TSC synchronization [CPU#0 -> CPU#1]:
Dec 16 12:48:57 UA-KVM1 kernel: Measured 906183720569 cycles TSC warp between CPUs, turning off TSC clock.
Dec 16 12:48:57 UA-KVM1 kernel: tsc: Marking TSC unstable due to check_tsc_sync_source failed
Dec 16 12:48:57 UA-KVM1 kernel: KVM setup async PF for cpu 1
Dec 16 12:48:57 UA-KVM1 kernel: kvm-stealtime: cpu 1, msr 3fd0d240
Dec 16 12:48:57 UA-KVM1 kernel: microcode: CPU1 sig=0x206c1, pf=0x1, revision=0x1
Dec 16 12:48:57 UA-KVM1 kernel: Will online and init hotplugged CPU: 1

Describe possible alternatives

We could give every firecracker microvm access to all cores and only use cgroups to limit actual scheduling time. This is not great though as it might create a lot of CPU steal. We prefer to give full cores when possible.

Checks

  • Have you searched the Firecracker Issues database for similar requests?
  • Have you read all the existing relevant Firecracker documentation?
  • Have you read and understood Firecracker's core tenets?
@KarthikNedunchezhiyan
Copy link
Contributor

@jeromegn does vertical scaling is the only solution to the problem you are to trying to fix? Does horizontal scaling like multiple instances not helped. Just curious to understand the usecase.

@raduiliescu
Copy link
Contributor

Hi @jeromegn!

You might also want to look at cpu online/offline kernel feature - https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu.
On the downside you will always need to start the microVM with the max number of CPUs, and you will need an agent inside the microVM to write the values in /proc, but the overhead of keeping CPUs offline is better than in the cgroup case.

@jeromegn
Copy link
Contributor Author

jeromegn commented Jun 3, 2021

@KarthikNedunchezhiyan we need to support a large variety of workloads. More VMs isn't always the solution, but we're already doing that.

@raduiliescu thanks! That could work, but our users have root access to the VM and could bring up any number of CPUs.

@AlexandruCihodaru
Copy link
Contributor

We need to think about it for a bit, we will get back to you.

@dianpopa dianpopa added Priority: Low Indicates that an issue or pull request should be resolved behind issues or pull requests labelled ` Roadmap: New Request labels Jun 30, 2021
@wearyzen wearyzen added the Status: Parked Indicates that an issues or pull request will be revisited later label Nov 13, 2023
@wearyzen
Copy link
Contributor

wearyzen commented Nov 13, 2023

marking this as parked right now but we will track this as part of our roadmap. We consider this as well while working on this.

@zulinx86 zulinx86 moved this to Researching in Firecracker Roadmap Jul 1, 2024
@zulinx86 zulinx86 added Status: WIP Indicates that an issue is currently being worked on or triaged and removed Status: Parked Indicates that an issues or pull request will be revisited later labels Jul 1, 2024
@roypat roypat added Status: Parked Indicates that an issues or pull request will be revisited later and removed Status: WIP Indicates that an issue is currently being worked on or triaged labels Nov 13, 2024
@roypat
Copy link
Contributor

roypat commented Nov 13, 2024

Hey all,
Just to leave a quick update here, we've prototyped vCPU hotplug in the feature/vcpu-hotplug feature branch. The results of performance testing there was that the end-to-end latency of hotplugging and on-lining an addition vCPU was ~30ms per vCPU, which is prohibitively expensive for the post-restore scenario (where we want to be able to resume guest execution within single digit milliseconds). As such, we're moving this ticket back to the backlog for now :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low Indicates that an issue or pull request should be resolved behind issues or pull requests labelled ` Roadmap: New Request Status: Parked Indicates that an issues or pull request will be revisited later
Projects
Status: Researching
Development

When branches are created from issues, their pull requests are automatically linked.

8 participants