我试图理解一个违反直觉的现象:当 CPU 空闲时,通过千兆连接我只能获得 ~ 400 Mbit/s,但当 CPU 满载时(压力测试实用程序),我可以获得 ~ 850 Mbit/s。我怀疑这是某些配置错误的症状,最终我希望能够使链接饱和,而不管 CPU 使用率如何。问题是:什么可能导致网络性能不佳,为什么它会以这种奇怪的方式依赖于 CPU 使用率?
我很高兴收到任何提示,感谢您的时间!
系统和硬件
- Lynx SENYO 迷你电脑 (GE5 PCF55)运行最新的 Arch Linux 内核版本 5.0.8(称为客户以供参考)。
网卡是 Realtek RTL8168:
# lspci -nn | grep Ethernet 08:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 03)
连接:CAT 6 跳线 <-> CAT 7 入墙电缆 <-> CAT 6 跳线场 <-> HPE OfficeConnect 交换机 <-> CAT 6 跳线 <-> Supermicro 家庭服务器(称为服务器(仅供参考)。另一台 PC 使用完全相同的电缆通过完全相同的服务器连接时,速度约为 950 Mbit/s,因此我猜这会将问题隔离到客户端。
测试设置
在服务器上:
# iperf3 -D -s --bind 192.168.128.1
在客户端上,当 CPU 空闲时:
# iperf3 -c 192.168.128.1 Connecting to host 192.168.128.1, port 5201 [ 5] local 192.168.128.100 port 60738 connected to 192.168.128.1 port 5201 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 39.8 MBytes 333 Mbits/sec 0 310 KBytes [ 5] 1.00-2.00 sec 40.5 MBytes 339 Mbits/sec 0 322 KBytes [ 5] 2.00-3.00 sec 40.3 MBytes 338 Mbits/sec 0 322 KBytes [ 5] 3.00-4.00 sec 41.0 MBytes 344 Mbits/sec 0 322 KBytes [ 5] 4.00-5.00 sec 36.9 MBytes 310 Mbits/sec 0 322 KBytes [ 5] 5.00-6.00 sec 53.1 MBytes 445 Mbits/sec 0 322 KBytes [ 5] 6.00-7.00 sec 53.7 MBytes 450 Mbits/sec 0 322 KBytes [ 5] 7.00-8.00 sec 54.7 MBytes 459 Mbits/sec 0 338 KBytes [ 5] 8.00-9.00 sec 54.0 MBytes 453 Mbits/sec 0 338 KBytes [ 5] 9.00-10.00 sec 54.0 MBytes 453 Mbits/sec 0 338 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 468 MBytes 393 Mbits/sec 0 sender [ 5] 0.00-10.04 sec 467 MBytes 390 Mbits/sec receiver
在客户端运行时
stress -c 4
(所有四个 CPU 都处于 100% 繁忙状态)# iperf3 -c 192.168.128.1 Connecting to host 192.168.128.1, port 5201 [ 5] local 192.168.128.100 port 60742 connected to 192.168.128.1 port 5201 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 102 MBytes 854 Mbits/sec 0 356 KBytes [ 5] 1.00-2.00 sec 101 MBytes 845 Mbits/sec 0 375 KBytes [ 5] 2.00-3.00 sec 101 MBytes 846 Mbits/sec 0 392 KBytes [ 5] 3.00-4.00 sec 101 MBytes 844 Mbits/sec 0 409 KBytes [ 5] 4.00-5.00 sec 100 MBytes 843 Mbits/sec 0 409 KBytes [ 5] 5.00-6.00 sec 101 MBytes 843 Mbits/sec 0 409 KBytes [ 5] 6.00-7.00 sec 101 MBytes 845 Mbits/sec 0 409 KBytes [ 5] 7.00-8.00 sec 100 MBytes 841 Mbits/sec 0 451 KBytes [ 5] 8.00-9.00 sec 101 MBytes 843 Mbits/sec 0 451 KBytes [ 5] 9.00-10.00 sec 101 MBytes 851 Mbits/sec 0 510 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 1008 MBytes 846 Mbits/sec 0 sender [ 5] 0.00-10.04 sec 1005 MBytes 840 Mbits/sec receiver
失败的尝试
- 我认为这可能是频率缩放问题,但
cpupower frequency-set -g performance
没有什么区别。 - 在阅读有关我的特定 NIC 的问题时,我尝试了两个驱动程序,一个存在于内核中 (r8169),另一个来自 Realtek (r8168)。总体情况相同,数字略有不同。使用 Realtek 驱动程序,我获得 556 Mbits/s(空闲 CPU)而不是 788 Mbits/s(繁忙 CPU)。
- 交叉检查了实时 Ubuntu 18.04 LTS(内核 4.18.0),结果相同。
- 跑步
irqbalance
没什么区别。 - 禁用 IPv6 没有什么区别。
附加信息(很高兴根据要求添加更多信息)
输出自ip
# ip addr show dev enp8s0
2: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:14:0b:81:3f:8a brd ff:ff:ff:ff:ff:ff
inet 192.168.128.100/24 brd 192.168.128.255 scope global noprefixroute enp8s0
valid_lft forever preferred_lft forever
输出自ethtool
:
# ethtool enp8s0
Settings for enp8s0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: yes
# ethtool -i enp8s0
driver: r8169
version:
firmware-version: rtl_nic/rtl8168d-1.fw
expansion-rom-version:
bus-info: 0000:08:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
中断:
# cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
...
26: 145689 0 0 394154 PCI-MSI 4194304-edge enp8s0
...
# cat /proc/softirqs
CPU0 CPU1 CPU2 CPU3
HI: 1 42 46 1
TIMER: 11550 32469 10688 11494
NET_TX: 85221 4 7 189091
NET_RX: 145692 0 14 394372
BLOCK: 21 450 39 22765
IRQ_POLL: 0 0 0 0
TASKLET: 136092 93 97 384278
SCHED: 10554 29735 8720 9726
HRTIMER: 0 0 0 0
RCU: 6154 8303 5838 6506