From cdcc20afccd537f1d869fbf73784200ddadc393b Mon Sep 17 00:00:00 2001 From: qingwangrh Date: Tue, 16 Jul 2024 17:18:09 +0800 Subject: [PATCH] block_performance_test: add performance test cases Add performance test cases: io_uring,iothread and iothread_vq_mapping Signed-off-by: qingwangrh --- qemu/tests/block_performance_test.py | 54 ++++++++++++------ qemu/tests/cfg/block_performance_test.cfg | 67 +++++++++++++++++++---- 2 files changed, 93 insertions(+), 28 deletions(-) diff --git a/qemu/tests/block_performance_test.py b/qemu/tests/block_performance_test.py index 0812f84244..b235f5034d 100644 --- a/qemu/tests/block_performance_test.py +++ b/qemu/tests/block_performance_test.py @@ -91,11 +91,11 @@ def preprcess_fio_filename(img): logger.debug(dev) if fio_raw_device == "yes": return dev - mount = "/home/%s" % (dev.replace("/dev/", "")) - cmd = "mkfs.xfs {0} && mkdir -p {1} && mount{0} {1}".format(dev, - mount) + mount_dir = "/home/%s" % (dev.replace("/dev/", "")) + cmd = "mkfs.xfs {0} && mkdir -p {1} && mount {0} {1}".format(dev, + mount_dir) session.cmd_output(cmd) - fio_filename = "%s/test.img" % mount + fio_filename = "%s/test.img" % mount_dir if not fio_filename: test.fail("Can not get output file path in guest.") @@ -127,6 +127,7 @@ def preprocess_fio_data(results): }, "results":[] "cmd": "", + "cmds":[], "location": "", "disk_name":"" } @@ -138,7 +139,8 @@ def preprocess_fio_data(results): opts = preprocess_fio_opts(results) for img in results["images"]: results[img] = {"filename": "", "global_options": {}, "jobs": {}, - "cmd": "", "location": "", "results": []} + "cmd": "", "cmds": [], "location": "", + "results": []} results[img]["location"] = params.get("fio_cmd_location_%s" % img, "vm") # guest fio @@ -152,6 +154,11 @@ def preprocess_fio_data(results): filename = preprcess_fio_filename(img) results[img]["cmd"] = "%s %s" % (fio_bin, opts % filename) + cmds = results[img]["cmd"].split("--stonewall") + if len(cmds) > 2 and fio_run_mode == "separate": + for i in range(1, len(cmds)): + results[img]["cmds"].append(cmds[0] + cmds[i]) + logger.debug(results) def run_fio_test(results): @@ -165,19 +172,32 @@ def run_fio_test(results): for img in results["images"]: if results[img]["location"] == "vm": - img_output = session.cmd_output(results[img]["cmd"], - timeout=cmd_timeout) + runner = session.cmd_output + else: + runner = process.getoutput + + if fio_iteration_cmd: + logger.debug(fio_iteration_cmd) + runner(fio_iteration_cmd) + + if results[img]["cmds"]: + cmd_num = len(results[img]["cmds"]) + for idx, cmd in enumerate(results[img]["cmds"]): + logger.debug(f"Run sub-cmd {idx}/{cmd_num}:{cmd}") + img_output = runner(cmd, cmd_timeout) + if i > 0: + # discard first result + parse_fio_result(img_output, img, results, record) else: - logger.debug(results[img]["cmd"]) - img_output = process.getoutput(results[img]["cmd"], - timeout=cmd_timeout) + logger.debug("Run full-cmd: %s", results[img]["cmd"]) + img_output = runner(results[img]["cmd"], cmd_timeout) + if i > 0: + # discard first result + parse_fio_result(img_output, img, results, record) + if fio_interval: time.sleep(fio_interval) - if i > 0: - # discard first result - parse_fio_result(img_output, img, results, record) - def parse_fio_result(cmd_output, img, results, record=False): # if record: # logger.debug(cmd_output) @@ -375,7 +395,7 @@ def process_selected_disk(disk): else: execute_operation("host", "mkfs.xfs -f %s " % disk) - execute_operation("host", "mount %s %s" % (disk, fio_dir)) + execute_operation("host", "mount %s %s && mount" % (disk, fio_dir)) umount_cmd = "umount -fl %s;" % fio_dir params["post_command"] = umount_cmd + params.get("post_command", "") @@ -490,8 +510,10 @@ def execute_operation(where, cmd): os_type = params["os_type"] login_timeout = params.get_numeric("login_timeout", 360) guest_operation = params.get("guest_operation") + fio_iteration_cmd = params.get("fio_iteration_cmd") + fio_run_mode = params.get("fio_run_mode", "separate") fio_interval = params.get_numeric("fio_interval") - cmd_timeout = params.get_numeric("cmd_timeout", 1800) + cmd_timeout = params.get_numeric("fio_cmd_timeout", 1800) run_times = params.get_numeric("run_times", 1) fio_dir = params["fio_dir"] test_results = {} diff --git a/qemu/tests/cfg/block_performance_test.cfg b/qemu/tests/cfg/block_performance_test.cfg index eff1ad7c9e..c84d31c697 100644 --- a/qemu/tests/cfg/block_performance_test.cfg +++ b/qemu/tests/cfg/block_performance_test.cfg @@ -21,16 +21,16 @@ drive_cache_stg2 = none drive_cache_stg3 = none - image_size_stg0 = 4224M - image_size_stg1 = 4352M - image_size_stg2 = 4480M - image_size_stg3 = 4608M + image_size_stg0 = 8320M + image_size_stg1 = 8448M + image_size_stg2 = 8576M + image_size_stg3 = 8704M - preallocation = falloc - preallocated_stg0 = falloc - preallocated_stg1 = falloc - preallocated_stg2 = falloc - preallocated_stg3 = falloc + preallocation = full + preallocated_stg0 = full + preallocated_stg1 = full + preallocated_stg2 = full + preallocated_stg3 = full blk_extra_params_stg0 = "serial=stg0" blk_extra_params_stg1 = "serial=stg1" @@ -76,30 +76,33 @@ pre_command = "if ! which fio;then yum install fio -y;fi &&" pre_command += " mkdir -p ${fio_dir};" - fio_cmd = " --runtime=20 --ramp_time=3 --size=4G --time_based=1 --direct=1 " + fio_cmd = " --runtime=20 --ramp_time=5 --size=8G --time_based=1 --direct=1 " fio_cmd += " --numjobs=8 --group_reporting --filename=%s " fio_cmd += " --randrepeat=1 --output-format=json " host_init_operation = lsblk host_deinit_operation = host_func_demo + # Merge and separate(default) + fio_run_mode = separate Linux: fio_cmd += " --ioengine=libaio " guest_init_operation = lsblk -n guest_deinit_operation = guest_func_demo + #fio_iteration_cmd = "echo 3 > /proc/sys/vm/drop_caches" Windows: vm_arch_name = i686 fio_cmd += " --thread " guest_init_operation = wmic diskdrive get Index,Name,Size - fio_rw = read write randrw + fio_rw = read write randread randwrite fio_iodepth = 64 fio_bs = 4k run_times = 6 variants: - with_queue_size: no i440fx - fio_stonewall_cmd +=" --stonewall --name=rw-512k-64 --rw=rw --bs=512k --iodepth=64 " images += ${compare_images} + fio_iodepth = 1 virtio_blk: blk_extra_params_stg0 += ",queue-size=128" blk_extra_params_stg1 += ",queue-size=1024" @@ -124,3 +127,43 @@ drive_bus_stg1 = 2 bus_extra_params_stg0 = "num_queues=1" bus_extra_params_stg1 = "num_queues=${vcpu_maxcpus}" + + - with_io_uring: + required_qemu = [8.1.0, ) + compare_images = " stg0 stg1 " + images += ${compare_images} + kparams = kernel.io_uring_disabled + kfile = /tmp/io_uring_disabled + pre_command += sysctl -n ${kparams} > ${kfile} && sysctl -w ${kparams}=0 + post_command += sysctl -n ${kparams} && sysctl -w ${kparams}=`cat ${kfile}`; + image_aio_stg0 = native + image_aio_stg1 = io_uring + + - with_iothread: + compare_images = " stg0 stg1 " + images += ${compare_images} + iothread_scheme ?= + image_iothread = + iothreads = t1 + image_iothread_stg0 = + image_iothread_stg1 = t1 + check_host_iops_req = 50000 + + - with_iothread_vq: + vcpu = 8 + vcpu_maxcpus = 8 + mem = 8192 + check_host_iops_req = 50000 + required_qemu = [8.2.0, ) + compare_images = " stg0 stg1 stg2 stg3 " + images += ${compare_images} + iothread_scheme ?= + image_iothread = + iothreads = t1 t2 t3 t4 + image_iothread_vq_mapping_stg1 = t1 + image_iothread_vq_mapping_stg2 = t1 t2 + image_iothread_vq_mapping_stg3 = t1 t2 t3 t4 + image_aio_stg0 = native + image_aio_stg1 = native + image_aio_stg2 = native + image_aio_stg3 = native