-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Virtio pmem perf tests #5479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ShadowCurse
wants to merge
6
commits into
firecracker-microvm:main
Choose a base branch
from
ShadowCurse:virtio_pmem_perf_tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Virtio pmem perf tests #5479
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e2c2e89
refactor: move fio related funcitons into separate file
ShadowCurse cee8a4b
feat(virtio-pmem): add performance tests
ShadowCurse 07696bb
feat(virtio-pmem): add memory saving test
ShadowCurse f777e8b
feat(virtio-pmem): add boottime tests
ShadowCurse eb7fb59
feat: add performance profile for pmem tests
ShadowCurse d9507a3
Merge branch 'main' into virtio_pmem_perf_tests
Manciukic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""File containing utility methods for fio-based performance tests""" | ||
|
||
import json | ||
import os | ||
from enum import Enum | ||
from pathlib import Path | ||
|
||
from framework.utils import CmdBuilder | ||
|
||
DEFAULT_RUNTIME_SEC = 30 | ||
DEFAULT_WARMUP_SEC = 10 | ||
|
||
|
||
class Mode(str, Enum): | ||
""" | ||
Modes of fio operation | ||
""" | ||
|
||
# Sequential reads. | ||
READ = "read" | ||
# Sequential writes. | ||
WRITE = "write" | ||
# Sequential trims (Linux block devices and SCSI character devices only). | ||
TRIM = "trim" | ||
# RANDOM reads. | ||
RANDREAD = "randread" | ||
# RANDOM writes. | ||
RANDWRITE = "randwrite" | ||
# RANDOM trims (Linux block devices and SCSI character devices only). | ||
RANDTRIM = "randtrim" | ||
# SEQUENTial mixed reads and writes. | ||
READWRITE = "readwrite" | ||
# RANDOM mixed reads and writes. | ||
RANDRW = "randrw" | ||
|
||
|
||
class Engine(str, Enum): | ||
""" | ||
Fio backend engines | ||
""" | ||
|
||
LIBAIO = "libaio" | ||
PSYNC = "psync" | ||
|
||
|
||
def build_cmd( | ||
file_path: str, | ||
file_size_mb: str | None, | ||
block_size: int, | ||
mode: Mode, | ||
num_jobs: int, | ||
io_engine: Engine, | ||
runtime: int | None = DEFAULT_RUNTIME_SEC, | ||
warmup_time: int | None = DEFAULT_WARMUP_SEC, | ||
write_logs: bool = True, | ||
) -> str: | ||
"""Build fio cmd""" | ||
|
||
cmd = ( | ||
CmdBuilder("fio") | ||
.with_arg(f"--name={mode.value}-{block_size}") | ||
.with_arg(f"--filename={file_path}") | ||
) | ||
|
||
if file_size_mb: | ||
cmd = cmd.with_arg(f"--size={file_size_mb}M") | ||
|
||
cmd = cmd.with_arg(f"--bs={block_size}") | ||
|
||
if runtime and warmup_time: | ||
cmd = ( | ||
cmd.with_arg("--time_based=1") | ||
.with_arg(f"--runtime={runtime}") | ||
.with_arg(f"--ramp_time={warmup_time}") | ||
) | ||
|
||
cmd = ( | ||
cmd.with_arg(f"--rw={mode.value}") | ||
.with_arg("--direct=1") | ||
.with_arg("--randrepeat=0") | ||
.with_arg(f"--ioengine={io_engine.value}") | ||
.with_arg("--iodepth=32") | ||
.with_arg(f"--numjobs={num_jobs}") | ||
# Set affinity of the entire fio process to a set of vCPUs equal | ||
# in size to number of workers | ||
.with_arg(f"--cpus_allowed={','.join(str(i) for i in range(num_jobs))}") | ||
# Instruct fio to pin one worker per vcpu | ||
.with_arg("--cpus_allowed_policy=split") | ||
.with_arg("--output-format=json+") | ||
.with_arg("--output=./fio.json") | ||
) | ||
|
||
if write_logs: | ||
cmd = cmd.with_arg("--log_avg_msec=1000").with_arg( | ||
f"--write_bw_log={mode.value}" | ||
) | ||
# Latency measurements only make sence for psync engine | ||
if io_engine == Engine.PSYNC: | ||
cmd = cmd.with_arg(f"--write_lat_log={mode}") | ||
|
||
return cmd.build() | ||
|
||
|
||
class LogType(Enum): | ||
"""Fio log types""" | ||
|
||
BW = "_bw" | ||
CLAT = "_clat" | ||
|
||
|
||
def process_log_files(root_dir: str, log_type: LogType) -> ([[str]], [[str]]): | ||
""" | ||
Parses fio logs which have a form of: | ||
1000, 2007920, 0, 0, 0 | ||
1000, 2005276, 1, 0, 0 | ||
2000, 1996240, 0, 0, 0 | ||
2000, 1993861, 1, 0, 0 | ||
... | ||
where the first column is the timestamp, second is the bw/clat and third is the direction | ||
|
||
The logs directory will look smth like this: | ||
readwrite_bw.1.log | ||
readwrite_bw.2.log | ||
readwrite_clat.1.log | ||
readwrite_clat.2.log | ||
readwrite_lat.1.log | ||
readwrite_lat.2.log | ||
readwrite_slat.1.log | ||
readwrite_slat.2.log | ||
|
||
job0 job1 | ||
read write read write | ||
[..] [..] [..] [..] | ||
| | | | | ||
| --|------- ---- | ||
| | ------| | | ||
[[], []] [[], []] | ||
reads writes | ||
|
||
The output is 2 arrays: array of reads and array of writes | ||
""" | ||
paths = [] | ||
for item in os.listdir(root_dir): | ||
if item.endswith(".log") and log_type.value in item: | ||
paths.append(Path(root_dir / item)) | ||
|
||
if not paths: | ||
return [], [] | ||
|
||
reads = [] | ||
writes = [] | ||
for path in sorted(paths): | ||
lines = path.read_text("UTF-8").splitlines() | ||
read_values = [] | ||
write_values = [] | ||
for line in lines: | ||
# See https://fio.readthedocs.io/en/latest/fio_doc.html#log-file-formats | ||
_, value, direction, _ = line.split(",", maxsplit=3) | ||
value = int(value.strip()) | ||
|
||
match direction.strip(): | ||
case "0": | ||
read_values.append(value) | ||
case "1": | ||
write_values.append(value) | ||
case _: | ||
assert False | ||
|
||
reads.append(read_values) | ||
writes.append(write_values) | ||
return reads, writes | ||
|
||
|
||
def process_json_files(root_dir: str) -> ([[int]], [[int]]): | ||
""" | ||
Reads `bw_bytes` values from fio*.json files and | ||
packs them into 2 arrays of bw_reads and bw_writes. | ||
Each entrly is an array in itself of `jobs` per file. | ||
""" | ||
paths = [] | ||
for item in os.listdir(root_dir): | ||
if item.endswith(".json") and "fio" in item: | ||
paths.append(Path(root_dir / item)) | ||
|
||
bw_reads = [] | ||
bw_writes = [] | ||
for path in sorted(paths): | ||
data = json.loads(path.read_text("UTF-8")) | ||
reads = [] | ||
writes = [] | ||
for job in data["jobs"]: | ||
if "read" in job: | ||
reads.append(job["read"]["bw_bytes"]) | ||
if "write" in job: | ||
writes.append(job["write"]["bw_bytes"]) | ||
bw_reads.append(reads) | ||
bw_writes.append(writes) | ||
return bw_reads, bw_writes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.