Add bw_tcp_virtio benchmark

This commit is contained in:
jiangjianfeng 2024-11-07 03:18:51 +00:00 committed by Tate, Hongliang Tian
parent 54e2ffbb71
commit 56727aa5ee
8 changed files with 65 additions and 3 deletions

View File

@ -76,7 +76,7 @@ run_benchmark() {
-drive if=none,format=raw,id=x0,file=${BENCHMARK_DIR}/../build/ext2.img \
-device virtio-blk-pci,bus=pcie.0,addr=0x6,drive=x0,serial=vext2,disable-legacy=on,disable-modern=off,queue-size=64,num-queues=1,request-merging=off,backend_defaults=off,discard=off,write-zeroes=off,event_idx=off,indirect_desc=off,queue_reset=off \
-append 'console=ttyS0 rdinit=/benchmark/common/bench_runner.sh ${benchmark} linux mitigations=off hugepages=0 transparent_hugepage=never quiet' \
-netdev user,id=net01,hostfwd=tcp::5201-:5201,hostfwd=tcp::6379-:6379,hostfwd=tcp::8080-:8080,hostfwd=tcp::31234-:31234 \
-netdev user,id=net01,hostfwd=tcp::5201-:5201,hostfwd=tcp::6379-:6379,hostfwd=tcp::8080-:8080,hostfwd=tcp::31234-:31234,hostfwd=tcp::31236-:31236 \
-device virtio-net-pci,netdev=net01,disable-legacy=on,disable-modern=off,mrg_rxbuf=off,ctrl_rx=off,ctrl_rx_extra=off,ctrl_vlan=off,ctrl_vq=off,ctrl_guest_offloads=off,ctrl_mac_addr=off,event_idx=off,queue_reset=off,guest_announce=off,indirect_desc=off \
-nographic \
2>&1"

View File

@ -29,6 +29,9 @@ elif [[ "$BENCHMARK_PATH" =~ "redis" ]]; then
elif [[ "$BENCHMARK_PATH" =~ "tcp_virtio_lat" ]]; then
# Persist lmbench/tcp_lat port
export LMBENCH_TCP_LAT_PORT=31234
elif [[ "$BENCHMARK_PATH" =~ "tcp_virtio_bw" ]]; then
# Persist lmbench/bw_tcp port
export LMBENCH_TCP_BW_PORT=31236
fi
# Function to run the benchmark

View File

@ -32,6 +32,7 @@
"tcp_loopback_connect_lat",
"tcp_loopback_select_lat",
"tcp_loopback_http_bw",
"tcp_virtio_bw_64k",
"udp_loopback_lat"
]
}

View File

@ -0,0 +1,9 @@
{
"alert_threshold": "125%",
"alert_tool": "customBiggerIsBetter",
"search_pattern": "0.065536 ",
"result_index": "2",
"description": "bw_tcp -l",
"title": "[TCP sockets] The bandwidth (virtio-net, 64KB message)",
"benchmark_type": "host_guest"
}

View File

@ -0,0 +1,21 @@
#!/bin/sh
# SPDX-License-Identifier: MPL-2.0
set -e
# Function to stop the guest VM
stop_guest() {
echo "Stopping guest VM..."
# `-r` means if there's no qemu, the kill won't be executed
pgrep qemu | xargs -r kill
}
# Trap EXIT signal to ensure guest VM is stopped on script exit
trap stop_guest EXIT
# Run lmbench tcp client
echo "Running lmbench tcp client"
/usr/local/benchmark/lmbench/bw_tcp -m 65536 -P 1 127.0.0.1
# The trap will automatically stop the guest VM when the script exits

View File

@ -0,0 +1,14 @@
[
{
"name": "Average TCP bandwidth on Linux",
"unit": "MB/sec",
"value": 0,
"extra": "linux_result"
},
{
"name": "Average TCP bandwidth on Asterinas",
"unit": "MB/sec",
"value": 0,
"extra": "aster_result"
}
]

View File

@ -0,0 +1,13 @@
#!/bin/sh
# SPDX-License-Identifier: MPL-2.0
set -e
echo "Running lmbench TCP latency over virtio-net..."
# Start the server
/benchmark/bin/lmbench/bw_tcp -s 10.0.2.15 -b 1
# Sleep for a long time to ensure VM won't exit
sleep 200

View File

@ -23,13 +23,14 @@ NGINX_RAND_PORT=${NGINX_PORT:-$(shuf -i 1024-65535 -n 1)}
REDIS_RAND_PORT=${REDIS_PORT:-$(shuf -i 1024-65535 -n 1)}
IPERF_RAND_PORT=${IPERF_PORT:-$(shuf -i 1024-65535 -n 1)}
LMBENCH_TCP_LAT_RAND_PORT=${LMBENCH_TCP_LAT_PORT:-$(shuf -i 1024-65535 -n 1)}
LMBENCH_TCP_BW_RAND_PORT=${LMBENCH_TCP_BW_PORT:-$(shuf -i 1024-65535 -n 1)}
# Optional QEMU arguments. Opt in them manually if needed.
# QEMU_OPT_ARG_DUMP_PACKETS="-object filter-dump,id=filter0,netdev=net01,file=virtio-net.pcap"
if [[ "$NETDEV" =~ "user" ]]; then
echo "[$1] Forwarded QEMU guest port: $SSH_RAND_PORT->22; $NGINX_RAND_PORT->8080 $REDIS_RAND_PORT->6379 $IPERF_RAND_PORT->5201 $LMBENCH_TCP_LAT_RAND_PORT->31234" 1>&2
NETDEV_ARGS="-netdev user,id=net01,hostfwd=tcp::$SSH_RAND_PORT-:22,hostfwd=tcp::$NGINX_RAND_PORT-:8080,hostfwd=tcp::$REDIS_RAND_PORT-:6379,hostfwd=tcp::$IPERF_RAND_PORT-:5201,hostfwd=tcp::$LMBENCH_TCP_LAT_RAND_PORT-:31234"
echo "[$1] Forwarded QEMU guest port: $SSH_RAND_PORT->22; $NGINX_RAND_PORT->8080 $REDIS_RAND_PORT->6379 $IPERF_RAND_PORT->5201 $LMBENCH_TCP_LAT_RAND_PORT->31234 $LMBENCH_TCP_BW_RAND_PORT->31236" 1>&2
NETDEV_ARGS="-netdev user,id=net01,hostfwd=tcp::$SSH_RAND_PORT-:22,hostfwd=tcp::$NGINX_RAND_PORT-:8080,hostfwd=tcp::$REDIS_RAND_PORT-:6379,hostfwd=tcp::$IPERF_RAND_PORT-:5201,hostfwd=tcp::$LMBENCH_TCP_LAT_RAND_PORT-:31234,hostfwd=tcp::$LMBENCH_TCP_BW_RAND_PORT-:31236"
elif [[ "$NETDEV" =~ "tap" ]]; then
THIS_SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
QEMU_IFUP_SCRIPT_PATH=$THIS_SCRIPT_DIR/net/qemu-ifup.sh