-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create initial performance tests measuring the time between hotplug API request and vCPUs being available to the guest. Note: These tests are NOT designed to be merged or used in CI, they are merely investigative tests for the latency of vCPU hotplugging Signed-off-by: James Curtis <[email protected]>
- Loading branch information
1 parent
0ba64b9
commit 5ed1a15
Showing
10 changed files
with
354 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SUBSYSTEM=="cpu", ACTION=="add", ATTR{online}!="1", ATTR{online}="1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# import pandas | ||
# import re | ||
# from framework.microvm import MicroVMFactory | ||
# | ||
# KERNEL = "vmlinux-5.10.221" | ||
# ROOTFS = "ubuntu-22.04.ext4" | ||
# | ||
# | ||
# def run_tests(): | ||
# factory = MicrovmFactory(fc_binary_path, jailer_binary_path) | ||
# manual_data = test_manual_latency(factory) | ||
# manual_data.to_csv("~/dev/results/manual_hotplug_data.csv") | ||
# | ||
# def test_manual_latency(microvm_factory): | ||
# """Test the latency for hotplugging and booting CPUs in the guest""" | ||
# fc_binary_path, jailer_binary_path = build_tools.get_firecracker_binaries() | ||
# df = pandas.DataFrame(columns=["vcpus", "api", "onlining"]) | ||
# gcc_compile(Path("./hotplug_time.c"), Path("./hotplug_time.o")) | ||
# data = [] | ||
# for vcpu_count in range(2, 30, 2): | ||
# for i in range(50): | ||
# uvm_hotplug = microvm_factory.build(KERNEL, ROOTFS) | ||
# uvm_hotplug.jailer.extra_args.update({"boot-timer": None, "no-seccomp": None}) | ||
# uvm_hotplug.help.enable_console() | ||
# uvm_hotplug.spawn() | ||
# uvm_hotplug.basic_config(vcpu_count=1, mem_size_mib=128) | ||
# uvm_hotplug.add_net_iface() | ||
# uvm_hotplug.start() | ||
# uvm_hotplug.ssh.scp_put(Path("./host_tools/hotplug.sh"), Path("/home/hotplug.sh")) | ||
# uvm_hotplug.ssh.scp_put(Path("./host_tools//hotplug_time.o"), Path("/home/hotplug_time.o")) | ||
# uvm_hotplug.ssh.run("tmux new-session -d /bin/bash /home/hotplug.sh > /home/test 2>&1") | ||
# | ||
# | ||
# uvm_hotplug.api.hotplug.put(Vcpu={"add": vcpu_count}) | ||
# | ||
# time.sleep(0.25) | ||
# # Extract API call duration | ||
# api_duration = float(re.findall(r"Total previous API call duration: (\d+) us\.", uvm_hotplug.log_data)[-1]) / 1000 | ||
# timestamp = float(re.findall(r"Guest-boot-time\s+\=\s+(\d+)\s+us", uvm_hotplug.log_data)[0]) / 1000 | ||
# data.append({"vcpus" : vcpu_count, "api": api_duration, "onlining": timestamp}) | ||
# return pandas.DataFrame.from_dict(data) | ||
|
||
# def test_custom_udev_latency(): | ||
# """Test the latency for hotplugging and booting CPUs in the guest""" | ||
# fc_binary_path, jailer_binary_path = build_tools.get_firecracker_binaries() | ||
# df = pandas.DataFrame(columns=["vcpus", "api", "onlining"]) | ||
# gcc_compile(Path("./hotplug_time.c"), Path("./hotplug_time.o")) | ||
# data = [] | ||
# for vcpu_count in range(2, 30, 2): | ||
# for i in range(50): | ||
# uvm_hotplug = microvm_factory.build(KERNEL, ROOTFS) | ||
# uvm_hotplug.jailer.extra_args.update({"boot-timer": None, "no-seccomp": None}) | ||
# uvm_hotplug.help.enable_console() | ||
# uvm_hotplug.spawn() | ||
# uvm_hotplug.basic_config(vcpu_count=1, mem_size_mib=128) | ||
# uvm_hotplug.add_net_iface() | ||
# uvm_hotplug.start() | ||
# uvm_hotplug.ssh.scp_put(Path("./host_tools/hotplug.sh"), Path("/home/hotplug.sh")) | ||
# uvm_hotplug.ssh.scp_put(Path("./host_tools//hotplug_time.o"), Path("/home/hotplug_time.o")) | ||
# uvm_hotplug.ssh.run("tmux new-session -d /bin/bash /home/hotplug.sh > /home/test 2>&1") | ||
# | ||
# | ||
# uvm_hotplug.api.hotplug.put(Vcpu={"add": vcpu_count}) | ||
# | ||
# time.sleep(0.25) | ||
# # Extract API call duration | ||
# api_duration = float(re.findall(r"Total previous API call duration: (\d+) us\.", uvm_hotplug.log_data)[-1]) / 1000 | ||
# timestamp = float(re.findall(r"Guest-boot-time\s+\=\s+(\d+)\s+us", uvm_hotplug.log_data)[0]) / 1000 | ||
# data.append({"vcpus" : vcpu_count, "api": api_duration, "onlining": timestamp}) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
while :; do | ||
[[ -d /sys/devices/system/cpu/cpu1 ]] && break | ||
done | ||
|
||
readarray -t offline_cpus < <(lscpu -p=cpu --offline | sed '/^#/d') | ||
|
||
for cpu_idx in ${offline_cpus[@]}; do | ||
echo 1 >/sys/devices/system/cpu/cpu$cpu_idx/online | ||
done | ||
|
||
/home/hotplug_time.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Init wrapper for boot timing. It points at /sbin/init. | ||
|
||
#include <fcntl.h> | ||
#include <sys/mman.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
// Base address values are defined in arch/src/lib.rs as arch::MMIO_MEM_START. | ||
// Values are computed in arch/src/<arch>/mod.rs from the architecture layouts. | ||
// Position on the bus is defined by MMIO_LEN increments, where MMIO_LEN is | ||
// defined as 0x1000 in vmm/src/device_manager/mmio.rs. | ||
#ifdef __x86_64__ | ||
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0xd0000000 | ||
#endif | ||
#ifdef __aarch64__ | ||
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0x40000000 | ||
#endif | ||
|
||
#define MAGIC_VALUE_SIGNAL_GUEST_BOOT_COMPLETE 123 | ||
|
||
int main() { | ||
int fd = open("/dev/mem", (O_RDWR | O_SYNC | O_CLOEXEC)); | ||
int mapped_size = getpagesize(); | ||
|
||
char *map_base = mmap(NULL, mapped_size, PROT_WRITE, MAP_SHARED, fd, | ||
MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE); | ||
|
||
*map_base = MAGIC_VALUE_SIGNAL_GUEST_BOOT_COMPLETE; | ||
msync(map_base, mapped_size, MS_ASYNC); | ||
} |
Binary file not shown.
Oops, something went wrong.