diff --git a/test/benchmark/README.md b/test/benchmark/README.md index a78ab9e0d..0bccf1d9e 100644 --- a/test/benchmark/README.md +++ b/test/benchmark/README.md @@ -253,7 +253,8 @@ The `bench_result.json` file configures how benchmark results are processed and }, // Optional runtime configurations for the benchmark. "runtime_config": { - "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 SMP CPUs (default to 1). } } ``` diff --git a/test/benchmark/bench_linux_and_aster.sh b/test/benchmark/bench_linux_and_aster.sh index 4ad0090d7..c6c866cf7 100755 --- a/test/benchmark/bench_linux_and_aster.sh +++ b/test/benchmark/bench_linux_and_aster.sh @@ -74,6 +74,7 @@ run_benchmark() { local benchmark="$1" local run_mode="$2" local aster_scheme="$3" + local smp="$4" echo "Preparing libraries..." prepare_libs @@ -89,10 +90,10 @@ run_benchmark() { fi # Prepare commands for Asterinas and Linux - local asterinas_cmd="make run BENCHMARK=${benchmark} ${aster_scheme_cmd} ENABLE_KVM=1 RELEASE_LTO=1 NETDEV=tap VHOST=on 2>&1" + 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 linux_cmd="/usr/local/qemu/bin/qemu-system-x86_64 \ --no-reboot \ - -smp 1 \ + -smp ${smp} \ -m 8G \ -machine q35,kernel-irqchip=split \ -cpu Icelake-Server,-pcid,+x2apic \ @@ -174,8 +175,17 @@ main() { done fi + local smp + if [[ -f "$bench_result" ]]; then + smp=$(jq -r '.runtime_config.smp // 1' "$bench_result") + else + for job in "${BENCHMARK_ROOT}/${benchmark}"/bench_results/*; do + [[ -f "$job" ]] && smp=$(jq -r '.runtime_config.smp // 1' "$job") && break + done + fi + # Run the benchmark - run_benchmark "$benchmark" "$run_mode" "$aster_scheme" + run_benchmark "$benchmark" "$run_mode" "$aster_scheme" "$smp" # Parse results if benchmark configuration exists if [[ -f "$bench_result" ]]; then