Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions lisa/microsoft/testsuites/performance/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
import pathlib
import time
from decimal import Decimal
from functools import partial
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast

Expand Down Expand Up @@ -63,6 +64,20 @@
DEFAULT_NTTTCP_CLIENT_TIMEOUT_TOLERANCE_SECONDS = 60


def _get_iperf_udp_bitrate(
udp_total_bitrate_gbps: Optional[Decimal], connections: int
) -> str:
if udp_total_bitrate_gbps is None:
return ""
per_stream_bitrate_mbps = (
udp_total_bitrate_gbps * Decimal(1000) / Decimal(connections)
)
bitrate = format(per_stream_bitrate_mbps.normalize(), "f")
if "." in bitrate:
bitrate = bitrate.rstrip("0").rstrip(".")
return f"{bitrate}M"


def perf_nvme(
node: Node,
result: TestResult,
Expand Down Expand Up @@ -376,6 +391,8 @@ def perf_ntttcp( # noqa: C901
# set server and client from environment, if not set explicitly
server = cast(RemoteNode, environment.nodes[1])
client = cast(RemoteNode, environment.nodes[0])
client_node = client
server_node = server

if not test_case_name:
# if it's not filled, assume it's called by case directly.
Expand All @@ -399,12 +416,12 @@ def perf_ntttcp( # noqa: C901

try:
client_ntttcp, server_ntttcp = run_in_parallel(
[lambda: client.tools[Ntttcp], lambda: server.tools[Ntttcp]] # type: ignore
[lambda: client_node.tools[Ntttcp], lambda: server_node.tools[Ntttcp]]
)
client_lagscope, server_lagscope = run_in_parallel(
[
lambda: client.tools[Lagscope], # type: ignore
lambda: server.tools[Lagscope], # type: ignore
lambda: client_node.tools[Lagscope],
lambda: server_node.tools[Lagscope],
]
)
# no need to set task max and reboot VM when connection less than 20480
Expand All @@ -417,6 +434,8 @@ def perf_ntttcp( # noqa: C901
need_reboot = True
else:
need_reboot = False
client_sriov_count = 0
server_sriov_count = 0
if need_reboot:
client_sriov_count = len(client.nics.get_pci_nics(exclude_ib=True))
server_sriov_count = len(server.nics.get_pci_nics(exclude_ib=True))
Expand Down Expand Up @@ -762,10 +781,11 @@ def perf_iperf(
connections: List[int],
buffer_length_list: List[int],
udp_mode: bool = False,
udp_total_bitrate_gbps: Optional[Decimal] = None,
server: Optional[RemoteNode] = None,
client: Optional[RemoteNode] = None,
run_with_internal_address: bool = False,
) -> None:
) -> List[Union[NetworkTCPPerformanceMessage, NetworkUDPPerformanceMessage]]:
if server is not None or client is not None:
assert server is not None, "server need to be specified, if client is set"
assert client is not None, "client need to be specified, if server is set"
Expand All @@ -775,12 +795,16 @@ def perf_iperf(
# set server and client from environment, if not set explicitly
client = cast(RemoteNode, environment.nodes[0])
server = cast(RemoteNode, environment.nodes[1])
client_node = client
server_node = server

client_iperf3, server_iperf3 = run_in_parallel(
[lambda: client.tools[Iperf3], lambda: server.tools[Iperf3]] # type: ignore
[lambda: client_node.tools[Iperf3], lambda: server_node.tools[Iperf3]]
)
test_case_name = inspect.stack()[1][3]
iperf3_messages_list: List[Any] = []
iperf3_messages_list: List[
Union[NetworkTCPPerformanceMessage, NetworkUDPPerformanceMessage]
] = []
server_interface_ip = ""
client_interface_ip = ""
if run_with_internal_address:
Expand Down Expand Up @@ -837,6 +861,11 @@ def perf_iperf(
report_unit="g",
port=current_client_port,
buffer_length=buffer_length,
bitrate=(
_get_iperf_udp_bitrate(udp_total_bitrate_gbps, connection)
if udp_mode
else ""
),
run_time_seconds=10,
parallel_number=num_threads_p,
ip_version="4",
Expand Down Expand Up @@ -874,6 +903,7 @@ def perf_iperf(
)
for iperf3_message in iperf3_messages_list:
notifier.notify(iperf3_message)
return iperf3_messages_list


def perf_sockperf(
Expand Down
Loading
Loading