Skip to content

Commit

Permalink
IoEngine(Enum)
Browse files Browse the repository at this point in the history
Const to Enum

to Enum

Update nvmeperf.py
  • Loading branch information
SRIKKANTH committed Sep 13, 2024
1 parent 138cf03 commit 847d358
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
3 changes: 2 additions & 1 deletion lisa/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from .fallocate import Fallocate
from .fdisk import Fdisk
from .find import Find
from .fio import FIOMODES, Fio, FIOResult
from .fio import FIOMODES, Fio, FIOResult, IoEngine
from .firewall import Firewall, Iptables
from .free import Free
from .gcc import Gcc
Expand Down Expand Up @@ -159,6 +159,7 @@
"Ip",
"IpInfo",
"Iperf3",
"IoEngine",
"HibernationSetup",
"Hostname",
"Hugepages",
Expand Down
24 changes: 17 additions & 7 deletions lisa/tools/fio.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ class FIOResult:
)


class IoEngine(Enum):
IO_URING = "io_uring"
LIBAIO = "libaio"
POSIXAIO = "posixaio"
NONE = ""

def __str__(self) -> str:
return self.value


class Fio(Tool):
fio_repo = "https://github.com/axboe/fio/"
branch = "fio-3.29"
Expand Down Expand Up @@ -93,7 +103,7 @@ def launch(
verify_dump: bool = False,
verify_fatal: bool = False,
verify: str = "",
ioengine: str = "",
ioengine: IoEngine = IoEngine.NONE,
cwd: Optional[pathlib.PurePath] = None,
) -> FIOResult:
cmd = self._get_command(
Expand Down Expand Up @@ -151,7 +161,7 @@ def launch_async(
verify_dump: bool = False,
verify_fatal: bool = False,
verify: str = "",
ioengine: str = "",
ioengine: IoEngine = IoEngine.NONE,
cwd: Optional[pathlib.PurePath] = None,
) -> Process:
cmd = self._get_command(
Expand Down Expand Up @@ -268,15 +278,15 @@ def _get_command( # noqa: C901
verify_dump: bool = False,
verify_fatal: bool = False,
verify: str = "",
ioengine: str = "",
ioengine: IoEngine = IoEngine.NONE,
) -> str:
if isinstance(self.node.os, BSD):
ioengine = constants.IO_ENGINE_POSIXAIO
elif ioengine == "":
ioengine = constants.IO_ENGINE_LIBAIO
ioengine = IoEngine.POSIXAIO
elif ioengine == IoEngine.NONE:
ioengine = IoEngine.LIBAIO

cmd = (
f"--ioengine={ioengine} --filename={filename} "
f"--ioengine={ioengine.value} --filename={filename} "
f"--readwrite={mode} --iodepth={iodepth} "
f"--name={name}"
)
Expand Down
4 changes: 0 additions & 4 deletions lisa/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,3 @@
SIGINT = 2
SIGTERM = 15
SIGKILL = 9

IO_ENGINE_IO_URING = "io_uring"
IO_ENGINE_LIBAIO = "libaio"
IO_ENGINE_POSIXAIO = "posixaio"
7 changes: 4 additions & 3 deletions microsoft/testsuites/performance/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@
Ssh,
Sysctl,
)
from lisa.tools.fio import IoEngine
from lisa.tools.ntttcp import (
NTTTCP_TCP_CONCURRENCY,
NTTTCP_TCP_CONCURRENCY_BSD,
NTTTCP_UDP_CONCURRENCY,
)
from lisa.util import constants, LisaException
from lisa.util import LisaException
from lisa.util.process import ExecutableResult, Process


Expand All @@ -70,7 +71,7 @@ def perf_disk(
size_mb: int = 0,
numjob: int = 0,
overwrite: bool = False,
ioengine: str = "",
ioengine: IoEngine = IoEngine.NONE,
cwd: Optional[pathlib.PurePath] = None,
) -> None:
fio_result_list: List[FIOResult] = []
Expand All @@ -87,7 +88,7 @@ def perf_disk(
# read: https://www.kernel.org/doc/Documentation/sysctl/fs.txt
# So we set numjob to 256 if numjob is larger than 256.
# This limitation is only needed for 'libaio' ioengine but not for 'io_uring'.
if ioengine == constants.IO_ENGINE_LIBAIO:
if ioengine == IoEngine.LIBAIO:
numjob = min(numjob, 256)
for mode in FIOMODES:
iodepth = start_iodepth
Expand Down
6 changes: 3 additions & 3 deletions microsoft/testsuites/performance/nvmeperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from lisa.messages import DiskSetupType, DiskType
from lisa.testsuite import TestResult
from lisa.tools import Echo, Lscpu
from lisa.util import constants
from lisa.tools.fio import IoEngine
from microsoft.testsuites.performance.common import perf_disk


Expand Down Expand Up @@ -82,7 +82,7 @@ def perf_nvme(self, node: Node, result: TestResult) -> None:
priority=3,
timeout=TIME_OUT,
requirement=simple_requirement(
supported_features=[NvmeSettings(disk_count=1)],
supported_features=[Nvme],
),
)
def perf_nvme_io_uring(self, node: Node, result: TestResult) -> None:
Expand Down Expand Up @@ -120,5 +120,5 @@ def perf_nvme_io_uring(self, node: Node, result: TestResult) -> None:
disk_setup_type=DiskSetupType.raw,
disk_type=DiskType.nvme,
test_result=result,
ioengine=constants.IO_ENGINE_IO_URING,
ioengine=IoEngine.IO_URING,
)

0 comments on commit 847d358

Please sign in to comment.