neondatabase / autoscaling

Postgres vertical autoscaling in k8s
Apache License 2.0
166 stars 21 forks source link

Replace hotplug cpu by online/offline CPU #1082

Open mikhail-sakhnov opened 2 months ago

mikhail-sakhnov commented 2 months ago

Problem description / Motivation

According to qemu documentation, hot plugging is not supported on arm. Marking cpu as online/offline is supported. We need to change acpi scripts used on x86_64 for hot plugging to support online/offline cpus on arm.

https://docs.kernel.org/next/arch/arm64/cpu-hotplug.html

https://www.qemu.org/docs/master/system/cpu-hotplug.html

Feature idea(s) / DoD

Implementation ideas

stradig commented 2 months ago

I suggest to move that to the start and also switch to online/offline on x86. I believe that will autoscaling also more robust on x86.

mikhail-sakhnov commented 2 months ago

CPU Scaling Feature via online/offline cpu state

Current Implementation

In the existing NeonVM platform, CPU hotplugging is used to dynamically scale CPU resources up or down. The NeonVM controller (neonvm/controllers/vm_controller.go) sends commands via QMP to the QEMU hypervisor. When CPUs are added or removed, a udev rule (neonvm/tools/vm-builder/files/vminit) inside the VM automatically marks the newly added CPUs as online.

While this method works effectively on x86_64 architectures, the ARM architecture in QEMU does not support CPU hotplugging.

Proposed Solution for ARM Architecture

To support CPU scaling on ARM, we will implement a different approach. Instead of hotplugging, all potential CPUs will be allocated to the VM instance during startup. Any CPUs beyond the current scaling limit will be marked as offline. The control of CPU states (online/offline) will no longer rely on the udev rule but will be handled through a VM control daemon running inside the VM.

Key Aspects:

Required Changes

mikhail-sakhnov commented 1 month ago

both related PRs are in review: #1104 and #1111

1090 been merged already.