25
2025
06
18:56:05

100G 网络速率调优—100G 基准测试

100G Benchmarking

在进行 100G(或更高速率)的基准测试时,你会希望能够得到稳定一致的测试结果。在 100G 的速度下,接收端很可能会受到 CPU 性能的限制,而且每个核心的性能表现都会略有差异(如这篇论文中所述)。因此,不仅需要明确指定应用程序所使用的核心,还需要指定中断请求(IRQ)所使用的核心。如果不这样做,很有可能会出现两条数据流的中断请求被分配到同一个核心上的情况,从而极大地影响性能。

论文链接: https://www.es.net/assets/pubs_presos/FGCS-Hanford.pdf

为了优化单流性能,你可以将中断请求(IRQ)和应用程序明确地映射到合适节点上相邻的核心。例如:

cat /sys/class/net/$ETH/device/numa_node  # 获取要使用的 NUMA 节点
numactl --hardware  # 找出该 NUMA 节点上相邻的核心
set_irq_affinity_cpulist.sh 8 $ETH
iperf3 -c hostname -A 9,9 -Z

另一种效果不错的策略是,在正确的 NUMA 节点上,将处理中断请求(IRQ)的核心与运行应用程序的核心分开。例如:

set_irq_affinity_cpulist.sh 0-7 $ETH
numactl -C 8-15 iperf3 (客户端和服务器端都执行)

例如,通过使用以下命令,我们在配备 200G 网卡的主机之间实现了 180Gbps 的传输速率:

set_irq_affinity_cpulist.sh 0-7 $ETH  # 客户端和服务器端都执行此操作
numactl -C 8-15 /usr/local/bin/iperf3 -s -D
numactl -C 8-15 /usr/local/bin/iperf3 -P 8 -c hostname --fq-rate 23G -t 60

请注意,在这个示例中使用了速率控制(pacing)。这是为了避免让接收端主机不堪重负,从而导致 TCP 重传。



对于并行数据流,你还可以使用 ethtool 工具来显式地分配中断请求(IRQ),并配置接收网络流分类规则。

例如,如果连接到你的网卡(如 eth100)的核心列表如下:

> cat /sys/class/net/eth100/device/local_cpulist
0-15

你希望将接收中断请求(IRQ)分配到核心 1-4,并在核心 12-15 上运行 iperf3,可以按以下步骤操作:

将端口 5002-5005 映射到网络队列(核心)1-4:

ethtool -U eth100 flow-type tcp4 dst-port 5002 action 1
ethtool -U eth100 flow-type tcp4 dst-port 5003 action 2
ethtool -U eth100 flow-type tcp4 dst-port 5004 action 3
ethtool -U eth100 flow-type tcp4 dst-port 5005 action 4

然后使用 iperf3 的 -A 选项来为客户端和服务器端指定要使用的核心。例如:

启动服务器端:

iperf3 -s -p 5002 & ; iperf3 -s -p 5003 & ; iperf3 -s -p 5004 & ; iperf3 -s -p 5005 & ;

运行客户端:

iperf3 -T "core 12" -c $host -t60 -A 12,12 -p 5002 -b 25G &
iperf3 -T "core 13" -c $host -t60 -A 13,13 -p 5003 -b 25G &
iperf3 -T "core 14" -c $host -t60 -A 14,14 -p 5004 -b 25G &
iperf3 -T "core 15" -c $host -t60 -A 15,15 -p 5005 -b 25G &

在干净的网络环境中,这样做应该能让你得到稳定且可重复的测试结果。

其他用于管理流量过滤规则的 ethtool 实用命令:

  • 查看规则结果:ethtool -u eth100
  • 删除这些规则:ethtool -U eth100 delete

Src

https://fasterdata.es.net/host-tuning/linux/100g-tuning/100g-benchmarking/

附录 set_irq_affinity_cpulist.sh


#! /bin/bash
#
# Copyright (c) 2017 Mellanox Technologies. All rights reserved.
#
# This Software is licensed under one of the following licenses:
#
# 1) under the terms of the "Common Public License 1.0" a copy of which is
#    available from the Open Source Initiative, see
#    http://www.opensource.org/licenses/cpl.php.
#
# 2) under the terms of the "The BSD License" a copy of which is
#    available from the Open Source Initiative, see
#    http://www.opensource.org/licenses/bsd-license.php.
#
# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
#    copy of which is available from the Open Source Initiative, see
#    http://www.opensource.org/licenses/gpl-license.php.
#
# Licensee has the right to choose one of the above licenses.
#
# Redistributions of source code must retain the above copyright
# notice and one of the license notices.
#
# Redistributions in binary form must reproduce both the above copyright
# notice, one of the license notices in the documentation
# and/or other materials provided with the distribution.
#
if [ -z $2 ]; then
echo"usage: $0 <cpu list> <interface or IB device> "
echo"       <cpu list> can be either a comma separated list of single core numbers (0,1,2,3) or core groups (0-3)"
exit 1
fi
cpulist=$1
interface=$2
NCPUS=$(cat /proc/cpuinfo | grep -c processor)
ONLINE_CPUS=$(cat /proc/cpuinfo | grep processor | cut -d ":" -f 2)

source common_irq_affinity.sh

IRQS=$( get_irq_list $interface )

if [ -z "$IRQS" ] ; then
        echo No IRQs found for$interface.
exit 1
fi

CORES=$( echo$cpulist | sed 's/,/ /g' | wc -w )
for word in $(seq 1 $CORES)
do
 SEQ=$(echo$cpulist | cut -d "," -f $word | sed 's/-/ /')
if [ "$(echo $SEQ | wc -w)" != "1" ]; then
  CPULIST="$CPULIST $( echo $(seq $SEQ) | sed 's/ /,/g' )"
fi
done
if [ "$CPULIST" != "" ]; then
 cpulist=$(echo$CPULIST | sed 's/ /,/g')
fi
CORES=$( echo$cpulist | sed 's/,/ /g' | wc -w )


echo Discovered irqs for$interface$IRQS
I=1
for IRQ in$IRQS
do
 core_id=$(echo$cpulist | cut -d "," -f $I)
 online=1
if [ $core_id -ge $NCPUS ]
then
  online=0
for online_cpu in$ONLINE_CPUS
do
   if [ "$online_cpu" == "$core_id" ]
   then
    online=1
    break
   fi
done
fi
if [ $online -eq 0 ]
then
echo"irq $IRQ: Error - core $core_id does not exist"
else
echo Assign irq $IRQ core_id $core_id
         affinity=$( core_to_affinity $core_id )
         set_irq_affinity $IRQ$affinity
fi
 I=$(( (I%CORES) + 1 ))
done
echo
echodone.




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://www.hqyman.cn/post/11886.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: