Add memory size configuration to benchmarks

This commit is contained in:
Fabing Li 2025-03-28 07:20:36 +00:00 committed by Tate, Hongliang Tian
parent 3c73672f52
commit 112cf087a6
2 changed files with 57 additions and 30 deletions

View File

@ -244,6 +244,8 @@ chart: # Chart configuration
runtime_config: # Runtime configuration runtime_config: # Runtime configuration
aster_scheme: "null" # Corresponds to Makefile parameters, IOMMU is enabled by default (SCHEME=iommu) aster_scheme: "null" # Corresponds to Makefile parameters, IOMMU is enabled by default (SCHEME=iommu)
smp: 1 # Number of CPUs to allocate to the VM
mem: 8G # Memory size in GB to allocate to the VM
``` ```
By adhering to this format, we ensure clarity and consistency in benchmarking workflows and reporting systems. By adhering to this format, we ensure clarity and consistency in benchmarking workflows and reporting systems.

View File

@ -72,32 +72,50 @@ extract_result_file() {
fi fi
} }
# Run the specified benchmark with optional scheme # Run the specified benchmark with runtime configurations
run_benchmark() { run_benchmark() {
local benchmark="$1" local benchmark="$1"
local run_mode="$2" local run_mode="$2"
local aster_scheme="$3" local runtime_configs_str="$3" # String with key=value pairs, one per line
local smp="$4"
echo "Preparing libraries..." echo "Preparing libraries..."
prepare_libs prepare_libs
# Set up Asterinas scheme if specified (Default: iommu) # Default values
local aster_scheme_cmd="SCHEME=iommu" local smp_val=1
if [ -n "$aster_scheme" ]; then local mem_val="8G"
if [ "$aster_scheme" != "null" ]; then local aster_scheme_cmd_part="SCHEME=iommu" # Default scheme
aster_scheme_cmd="SCHEME=${aster_scheme}"
# Process runtime_configs_str to override defaults and gather extra args
while IFS='=' read -r key value; do
if [[ -z "$key" ]]; then continue; fi # Skip empty lines/keys
case "$key" in
"smp")
smp_val="$value"
;;
"mem")
mem_val="$value"
;;
"aster_scheme")
if [[ "$value" == "null" ]]; then
aster_scheme_cmd_part="" # Remove default SCHEME=iommu
else else
aster_scheme_cmd="" aster_scheme_cmd_part="SCHEME=${value}" # Override default
fi
fi fi
;;
*)
echo "Warning: Unknown runtime configuration key '$key'" >&2
exit 1
;;
esac
done <<< "$runtime_configs_str"
# Prepare commands for Asterinas and Linux # Prepare commands for Asterinas and Linux
local asterinas_cmd="make run BENCHMARK=${benchmark} ${aster_scheme_cmd} SMP=${smp} ENABLE_KVM=1 RELEASE_LTO=1 NETDEV=tap VHOST=on 2>&1" local asterinas_cmd="make run BENCHMARK=${benchmark} ${aster_scheme_cmd_part} SMP=${smp_val} MEM=${mem_val} ENABLE_KVM=1 RELEASE_LTO=1 NETDEV=tap VHOST=on 2>&1"
local linux_cmd="/usr/local/qemu/bin/qemu-system-x86_64 \ local linux_cmd="/usr/local/qemu/bin/qemu-system-x86_64 \
--no-reboot \ --no-reboot \
-smp ${smp} \ -smp ${smp_val} \
-m 8G \ -m ${mem_val} \
-machine q35,kernel-irqchip=split \ -machine q35,kernel-irqchip=split \
-cpu Icelake-Server,-pcid,+x2apic \ -cpu Icelake-Server,-pcid,+x2apic \
--enable-kvm \ --enable-kvm \
@ -111,6 +129,10 @@ run_benchmark() {
-nographic \ -nographic \
2>&1" 2>&1"
# Trim leading/trailing whitespace from commands before eval
asterinas_cmd=$(echo "$asterinas_cmd" | sed 's/^ *//;s/ *$//;s/ */ /g')
linux_cmd=$(echo "$linux_cmd" | sed 's/^ *//;s/ *$//;s/ */ /g')
# Run the benchmark depending on the mode # Run the benchmark depending on the mode
case "${run_mode}" in case "${run_mode}" in
"guest_only") "guest_only")
@ -170,26 +192,29 @@ main() {
[[ -f "${BENCHMARK_ROOT}/${benchmark}/host.sh" ]] && run_mode="host_guest" [[ -f "${BENCHMARK_ROOT}/${benchmark}/host.sh" ]] && run_mode="host_guest"
local bench_result="${BENCHMARK_ROOT}/${benchmark}/bench_result.yaml" local bench_result="${BENCHMARK_ROOT}/${benchmark}/bench_result.yaml"
local aster_scheme local runtime_configs_str=""
# Try reading from single result file first
if [[ -f "$bench_result" ]]; then if [[ -f "$bench_result" ]]; then
aster_scheme=$(yq -r '.runtime_config.aster_scheme // ""' "$bench_result") # Read runtime_config object, convert to key=value lines, ensuring value is string
runtime_configs_str=$(yq -r '(.runtime_config // {}) | to_entries | .[] | .key + "=" + (.value | tostring)' "$bench_result")
else else
for job in "${BENCHMARK_ROOT}/${benchmark}"/bench_results/*; do # If not found, try reading from the first file in bench_results/ that has a non-empty runtime_config
[[ -f "$job" ]] && aster_scheme=$(yq -r '.runtime_config.aster_scheme // ""' "$job") && break for job_yaml in "${BENCHMARK_ROOT}/${benchmark}"/bench_results/*; do
if [[ -f "$job_yaml" ]]; then
echo "Reading runtime configurations from $job_yaml..."
# Read runtime_config object, convert to key=value lines, ensuring value is string
runtime_configs_str=$(yq -r '(.runtime_config // {}) | to_entries | .[] | .key + "=" + (.value | tostring)' "$job_yaml")
# Check if runtime_config was actually found and non-empty
if [[ -n "$runtime_configs_str" ]]; then
break # Found it, stop looking
fi
fi
done done
fi fi
local smp # Run the benchmark, passing the config string
if [[ -f "$bench_result" ]]; then run_benchmark "$benchmark" "$run_mode" "$runtime_configs_str"
smp=$(yq -r '.runtime_config.smp // 1' "$bench_result")
else
for job in "${BENCHMARK_ROOT}/${benchmark}"/bench_results/*; do
[[ -f "$job" ]] && smp=$(yq -r '.runtime_config.smp // 1' "$job") && break
done
fi
# Run the benchmark
run_benchmark "$benchmark" "$run_mode" "$aster_scheme" "$smp"
# Parse results if benchmark configuration exists # Parse results if benchmark configuration exists
if [[ -f "$bench_result" ]]; then if [[ -f "$bench_result" ]]; then