e2e_tests/benches: Add gimp benchmark for disk performance

Gimp plugin initializing, loading and file batch processing are
plausible real-world operations to run under crosvm, and can be
easily measured in an automated gui-less fasion. These operations
mainly stress small file disk performance.

BUG=b:181105093

TEST=./tools/bench gimp

Change-Id: I5891771a031f5843df4aebdfede8ae9b7ed53977
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4994843
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Zihan Chen 2023-10-31 12:58:28 -07:00 committed by crosvm LUCI
parent ecd5795b45
commit 60a419217c
3 changed files with 71 additions and 0 deletions

37
e2e_tests/benches/gimp.rs Normal file
View file

@ -0,0 +1,37 @@
// Copyright 2023 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use std::time::Duration;
use fixture::vm::Config;
use fixture::vm::TestVm;
#[test]
fn gimp() -> anyhow::Result<()> {
let cfg = Config::new()
.with_kernel("https://storage.googleapis.com/crosvm/integration_tests/guest-bzimage-x86_64-r0009")
.with_initrd("https://storage.googleapis.com/crosvm/integration_tests/benchmarks/custom-initramfs.cpio.gz-r0005")
// Created by e2e_tests/guest_under_test/rootfs_benches/gimp/make.sh
.with_rootfs("https://storage.googleapis.com/crosvm/integration_tests/benchmarks/gimp-rootfs.img.zst-r0001").rootfs_is_rw().rootfs_is_compressed()
.with_stdout_hardware("serial").extra_args(vec!["--mem".to_owned(), "1024".to_owned()]);
let mut vm = TestVm::new(cfg).unwrap();
assert_eq!(
vm.exec_in_guest_async("echo 42")?
.with_timeout(Duration::from_secs(500))
.wait_ok(&mut vm)?
.stdout
.trim(),
"42"
);
vm.exec_in_guest("cd /workdir")?;
// Time initializing all plugins and execute action
vm.exec_in_guest(
r#"/usr/bin/gimp -i -b '(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "/workdir/test1.png" "/workdir/test1.png")))(drawable (car (gimp-image-get-active-layer image)))) (plug-in-mblur RUN-NONINTERACTIVE image drawable 1 0 45 200 200) (gimp-file-save RUN-NONINTERACTIVE image drawable "/workdir/out1.png" "/workdir/out1.png"))' -b '(gimp-quit 0)'"#,
)?;
// Time executing action only
vm.exec_in_guest(
r#"/usr/bin/gimp -i -b '(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "/workdir/test2.png" "/workdir/test2.png")))(drawable (car (gimp-image-get-active-layer image)))) (plug-in-mblur RUN-NONINTERACTIVE image drawable 1 0 45 200 200) (gimp-file-save RUN-NONINTERACTIVE image drawable "/workdir/out2.png" "/workdir/out2.png"))' -b '(gimp-quit 0)'"#,
)?;
Ok(())
}

View file

@ -0,0 +1,18 @@
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
FROM debian:bookworm
# Install many gimp plugins and data to make the initialize time longer
RUN apt-get update \
&& apt-get install --no-install-recommends --yes wget gimp gimp-data-extras gimp-lensfun gimp-texturize \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /workdir
WORKDIR /workdir
ADD logo/logo_512.png test1.png
RUN cp test1.png test2.png

View file

@ -0,0 +1,16 @@
#!/bin/bash
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Generate compressed rootfs image for gimp e2e benchmark
# Result will be stored as /tmp/crosvm_e2e_test_guest_gimp.img.zst
cd "$(dirname "$0")"
podman build -t crosvm_e2e_test_guest_gimp ../../../../ -f e2e_tests/guest_under_test/rootfs_benches/gimp/ContainerFile
CONTAINER=$(podman create crosvm_e2e_test_guest_gimp)
podman export $CONTAINER > /tmp/crosvm_e2e_test_guest_gimp.tar
podman rm $CONTAINER
virt-make-fs --format=raw --size=+100M --type=ext4 /tmp/crosvm_e2e_test_guest_gimp.tar /tmp/crosvm_e2e_test_guest_gimp.img
rm /tmp/crosvm_e2e_test_guest_gimp.tar
zstd --rm /tmp/crosvm_e2e_test_guest_gimp.img