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
4 changes: 4 additions & 0 deletions lisa/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ class NetworkTCPPerformanceMessage(PerfMessage):
retransmitted_segments: Decimal = Decimal(0)
congestion_windowsize_kb: Decimal = Decimal(0)
protocol_type: Optional[str] = TransportProtocol.Tcp
client_mtu: int = -1
server_mtu: int = -1


@dataclass
Expand All @@ -266,6 +268,8 @@ class NetworkUDPPerformanceMessage(PerfMessage):
data_loss: Decimal = Decimal(0)
packet_size_kbytes: Decimal = Decimal(0)
protocol_type: Optional[str] = TransportProtocol.Udp
client_mtu: int = -1
server_mtu: int = -1


@dataclass
Expand Down
12 changes: 12 additions & 0 deletions lisa/tools/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ def restart_device(
),
)

def is_valid_mtu(self, value: Optional[int] = None) -> bool:
if value is None:
return False
try:
mtu = int(value)
# typical MTU values are between 576 and 9000
# 576 is the minimum possible MTU for IPv4 and 1280 for IPv6
# 9000 is a common value for jumbo frames on Ethernet networks
return 576 <= mtu <= 9000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone sets the value to 570 but it runs with a different value, it should raise an exception and fail the case instead of silently using the default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_mtu has this logic already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the logic, if the MTU is out of range, the function returns false and sets MTU to None, which is unexpected. If you want set_mtu to fail via command, remove the check here.

except ValueError:
raise LisaException("MTU value is not an integer")

def get_mtu(self, nic_name: str) -> int:
cat = self.node.tools[Cat]
return int(cat.read(f"/sys/class/net/{nic_name}/mtu", force_run=True))
Expand Down
58 changes: 58 additions & 0 deletions lisa/tools/ntttcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class NtttcpResult:
rx_packets: Decimal = Decimal(0)
pkts_interrupt: Decimal = Decimal(0)
cycles_per_byte: Decimal = Decimal(0)
mtu: int = -1


class Ntttcp(Tool):
Expand Down Expand Up @@ -389,10 +390,16 @@ def create_ntttcp_tcp_performance_message(
buffer_size: int,
test_case_name: str,
test_result: "TestResult",
client_mtu: int = -1,
server_mtu: int = -1,
) -> NetworkTCPPerformanceMessage:
other_fields: Dict[str, Any] = {}
other_fields["tool"] = constants.NETWORK_PERFORMANCE_TOOL_NTTTCP
other_fields["buffer_size"] = Decimal(buffer_size)
if client_mtu != -1:
other_fields["client_mtu"] = client_mtu
if server_mtu != -1:
other_fields["server_mtu"] = server_mtu
other_fields["connections_created_time"] = int(
client_result.connections_created_time
)
Expand All @@ -415,6 +422,8 @@ def create_ntttcp_tcp_performance_message(
buffer_size,
test_case_name,
test_result,
client_mtu,
server_mtu,
)

return create_perf_message(
Expand All @@ -433,10 +442,14 @@ def create_ntttcp_udp_performance_message(
buffer_size: int,
test_case_name: str,
test_result: "TestResult",
client_mtu: int = -1,
server_mtu: int = -1,
) -> NetworkUDPPerformanceMessage:
other_fields: Dict[str, Any] = {}
other_fields["tool"] = constants.NETWORK_PERFORMANCE_TOOL_NTTTCP
other_fields["send_buffer_size"] = Decimal(buffer_size)
other_fields["client_mtu"] = client_mtu
other_fields["server_mtu"] = server_mtu
other_fields["connections_created_time"] = int(
client_result.connections_created_time
)
Expand All @@ -458,6 +471,8 @@ def create_ntttcp_udp_performance_message(
buffer_size,
test_case_name,
test_result,
client_mtu,
server_mtu,
)

return create_perf_message(
Expand Down Expand Up @@ -500,6 +515,8 @@ def send_ntttcp_tcp_unified_perf_messages(
buffer_size: int,
test_case_name: str,
test_result: "TestResult",
client_mtu: int,
server_mtu: int,
) -> None:
"""Send unified performance messages for TCP ntttcp metrics."""
# Include connections_num in metric names to distinguish results
Expand Down Expand Up @@ -567,6 +584,25 @@ def send_ntttcp_tcp_unified_perf_messages(
"unit": "cycles/byte",
},
]
# Only send MTU metrics if they are valid (not -1)
if client_mtu != -1:
metrics.append(
{
"name": f"client_mtu{conn_suffix}",
"value": int(client_mtu),
"relativity": MetricRelativity.NA,
"unit": "bytes",
}
)
if server_mtu != -1:
metrics.append(
{
"name": f"server_mtu{conn_suffix}",
"value": int(server_mtu),
"relativity": MetricRelativity.NA,
"unit": "bytes",
},
)

self._send_unified_perf_metrics(
metrics, test_case_name, test_result, TransportProtocol.Tcp
Expand All @@ -580,6 +616,8 @@ def send_ntttcp_udp_unified_perf_messages(
buffer_size: int,
test_case_name: str,
test_result: "TestResult",
client_mtu: int,
server_mtu: int,
) -> None:
"""Send unified performance messages for UDP ntttcp metrics."""
# Include connections_num in metric names to distinguish results
Expand Down Expand Up @@ -631,6 +669,26 @@ def send_ntttcp_udp_unified_perf_messages(
},
]

# Only send MTU metrics if they are valid (not -1)
if client_mtu != -1:
metrics.append(
{
"name": f"client_mtu{conn_suffix}",
"value": int(client_mtu),
"relativity": MetricRelativity.NA,
"unit": "bytes",
}
)
if server_mtu != -1:
metrics.append(
{
"name": f"server_mtu{conn_suffix}",
"value": int(server_mtu),
"relativity": MetricRelativity.NA,
"unit": "bytes",
},
)

self._send_unified_perf_metrics(
metrics, test_case_name, test_result, TransportProtocol.Udp
)
Expand Down
24 changes: 24 additions & 0 deletions microsoft/testsuites/performance/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
Sysctl,
)
from lisa.tools.fio import IoEngine
from lisa.tools.ip import Ip
from lisa.tools.ntttcp import (
NTTTCP_TCP_CONCURRENCY,
NTTTCP_TCP_CONCURRENCY_BSD,
Expand Down Expand Up @@ -309,6 +310,7 @@ def perf_ntttcp( # noqa: C901
lagscope_server_ip: Optional[str] = None,
server_nic_name: Optional[str] = None,
client_nic_name: Optional[str] = None,
variables: Optional[Dict[str, Any]] = None,
) -> List[Union[NetworkTCPPerformanceMessage, NetworkUDPPerformanceMessage]]:
# Either server and client are set explicitly or we use the first two nodes
# from the environment. We never combine the two options. We need to specify
Expand Down Expand Up @@ -364,6 +366,20 @@ def perf_ntttcp( # noqa: C901
ntttcp.setup_system(udp_mode, set_task_max)
for lagscope in [client_lagscope, server_lagscope]:
lagscope.set_busy_poll()
client_nic = client.nics.default_nic
server_nic = server.nics.default_nic
client_ip = client.tools[Ip]
server_ip = server.tools[Ip]
mtu = variables.get("perf_ntttcp_mtu", None) if variables is not None else None
if client_ip.is_valid_mtu(mtu) and mtu is not None:
# set mtu for default nics
client_ip.set_mtu(client_nic, mtu)
server_ip.set_mtu(server_nic, mtu)
else:
mtu = None
client_mtu = client_ip.get_mtu(client_nic)
server_mtu = server_ip.get_mtu(server_nic)

data_path = get_nic_datapath(client)
if NetworkDataPath.Sriov.value == data_path:
if need_reboot:
Expand All @@ -382,6 +398,10 @@ def perf_ntttcp( # noqa: C901
else client.nics.get_primary_nic().pci_device_name
)
dev_differentiator = "mlx"
if mtu is not None:
# set mtu for AN nics, MTU needs to be set on both AN and non-AN nics
client_ip.set_mtu(client_nic_name, mtu)
server_ip.set_mtu(server_nic_name, mtu)
else:
server_nic_name = (
server_nic_name if server_nic_name else server.nics.default_nic
Expand Down Expand Up @@ -461,6 +481,8 @@ def perf_ntttcp( # noqa: C901
buffer_size,
test_case_name,
test_result,
client_mtu,
server_mtu,
)
else:
ntttcp_message = client_ntttcp.create_ntttcp_tcp_performance_message(
Expand All @@ -471,6 +493,8 @@ def perf_ntttcp( # noqa: C901
buffer_size,
test_case_name,
test_result,
client_mtu,
server_mtu,
)
notifier.notify(ntttcp_message)
perf_ntttcp_message_list.append(ntttcp_message)
Expand Down
30 changes: 20 additions & 10 deletions microsoft/testsuites/performance/networkperf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from functools import partial
from typing import Any
from typing import Any, Dict

from lisa import (
Logger,
Expand Down Expand Up @@ -145,7 +145,9 @@ def perf_tcp_max_pps_sriov(self, result: TestResult) -> None:
network_interface=Synthetic(),
),
)
def perf_tcp_ntttcp_128_connections_synthetic(self, result: TestResult) -> None:
def perf_tcp_ntttcp_128_connections_synthetic(
self, result: TestResult, variables: Dict[str, Any]
) -> None:
perf_ntttcp(result, connections=[128])

@TestCaseMetadata(
Expand All @@ -162,8 +164,10 @@ def perf_tcp_ntttcp_128_connections_synthetic(self, result: TestResult) -> None:
)
),
)
def perf_tcp_ntttcp_synthetic(self, result: TestResult) -> None:
perf_ntttcp(result)
def perf_tcp_ntttcp_synthetic(
self, result: TestResult, variables: Dict[str, Any]
) -> None:
perf_ntttcp(result, variables=variables)

@TestCaseMetadata(
description="""
Expand All @@ -179,8 +183,10 @@ def perf_tcp_ntttcp_synthetic(self, result: TestResult) -> None:
)
),
)
def perf_tcp_ntttcp_sriov(self, result: TestResult) -> None:
perf_ntttcp(result)
def perf_tcp_ntttcp_sriov(
self, result: TestResult, variables: Dict[str, Any]
) -> None:
perf_ntttcp(result, variables=variables)

@TestCaseMetadata(
description="""
Expand All @@ -194,8 +200,10 @@ def perf_tcp_ntttcp_sriov(self, result: TestResult) -> None:
unsupported_os=[BSD, Windows],
),
)
def perf_udp_1k_ntttcp_synthetic(self, result: TestResult) -> None:
perf_ntttcp(result, udp_mode=True)
def perf_udp_1k_ntttcp_synthetic(
self, result: TestResult, variables: Dict[str, Any]
) -> None:
perf_ntttcp(result, udp_mode=True, variables=variables)

@TestCaseMetadata(
description="""
Expand All @@ -209,8 +217,10 @@ def perf_udp_1k_ntttcp_synthetic(self, result: TestResult) -> None:
unsupported_os=[BSD, Windows],
),
)
def perf_udp_1k_ntttcp_sriov(self, result: TestResult) -> None:
perf_ntttcp(result, udp_mode=True)
def perf_udp_1k_ntttcp_sriov(
self, result: TestResult, variables: Dict[str, Any]
) -> None:
perf_ntttcp(result, udp_mode=True, variables=variables)

@TestCaseMetadata(
description="""
Expand Down
Loading