基于DPDK的MellanoxCX4-40G网卡性能测试

2023-10-10 02:59

本文主要是介绍基于DPDK的MellanoxCX4-40G网卡性能测试,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1、硬件环境

a)      服务器:Sugon W560-G20 workstation

b)      处理器:Intel Xeno E5 -2660 V3处理器(2.60GHz) 20 CPU cores*2 NUMA nodes

c)      内存:128G,2*32GB DIMMs * 2NUMA nodes 2133MHz

d)      主板:S7070A2NR-B,PCIe_4x16(CPU0),PCIe_2x16(CPU1)

e)      网卡:Mellanox ConnectX-4 Lx 40GbE网卡(model No:CX416A)

2、软件环境

a)      操作系统:RedHat Linux 7.1

(default_hugepage_size=4G 2048*2M)

b)      BIOS:AMI v7.102.R01 2016/3/30

(Power Profile PERFORMANCE; C-states OFF; P-states OFF;TurboBoost ON; HyperThreading OFF; Virt OFF; VTd OFF; SR-IOV OFF; SMI OFFIONonPostedPrefetching OFF;)

c)      内核版本:3.10.0-229.el7.x86_64

d)      网卡固件版本:14.18.2000

e)      网卡驱动版本:MLNX_OFED_LINUX-4.1-1.0.2.0-rhel7.1-x86_64

f)       DPDK版本:MellanoxDPDK 16.11_3.0

(启用mlx5 PMD,CONFIG_RTE_LIBRTE_MLX5_PMD=y)

g)      Ans版本(2017-11-23):基于dpdk17.05.2

 

3、测试环境

测试分两种情形,一种是针对数据包进行简单的收发测试,另一种是在对数据包进行三层协议转发条件下进行测试。

 

图1 DPDKTestpmd性能测试环境

如上图所示,在测试环境A中,TestPMD应用程序把同一块网卡的两个以太网端口连成环回模式。这样可以在没有外部流量发生器的情况下检查网络设备的接收和传输功能。发送的数据包为UDP数据包。


图2 DPDK下使用ANS进行转发测试

在测试环境B中,Port3绑定pktgen,port1绑定ans。Port1和port3中间通过交换机相连,ans从Port1发送UDP数据包到port3。

4、测试工具

使用Mellanox DPDK 16.11_3.0内提供的测试工具Testpmd

基于DPDK 的含协议栈的应用ans及发包程序dpdk-udp

基于DPDK的发包程序pktgen-3.4.2

网卡收发报文速率统计脚本eth_stat.sh

5、测试结果

表1 测试环境A下测试结果

序号

Pkt_data_len

DEF_PKT_BURST

nbcore

nb_rxq/txq

RTE_TEST_RX_DESC_DEFAULT

RTE_TEST_TX_DESC_DEFAULT

Gbps

1

64

32

1

1

128

512

4.1

2

64

32

2

1

128

512

4.2

3

64

32

3

1

128

512

4.2

4

64

64

2

1

128

512

4.6

5

64

64

4

1

128

512

5.7

6

64

128

1

1

128

512

5.0

7

64

128

2

1

128

512

5.0

8

64

128

3

1

128

512

5.0

9

64

256

1

1

128

512

4.9

10

64

256

2

1

128

512

5.0

11

64

256

3

1

128

512

5.0

12

64

512

1

1

128

512

4.9

13

64

512

2

1

128

512

5.0

14

64

512

3

1

128

512

5.0

15

64

512

4

1

128

512

6.3

16

64

32

1

2

128

512

4.5

17

64

32

2

2

128

512

4.7

18

64

32

3

2

128

512

4.7

19

64

64

2

2

128

512

5.2

20

64

64

4

2

128

512

6.3

21

64

128

4

2

128

512

6.3

22

64

128

3

3

128

512

6.3

23

64

256

4

3

128

512

6.3

24

64

256

4

4

128

512

6.3

25

128

32

1

1

128

512

7.1

26

128

32

2

1

128

512

7.3

27

128

32

3

1

128

512

7.3

28

128

32

4

1

128

512

7.4

29

128

64

4

1

128

512

9.4

30

128

128

2

1

128

512

8.7

31

128

256

4

1

128

512

10.3

32

128

64

4

2

128

512

10.3

33

128

256

4

4

128

512

10.3

34

256

32

2

2

128

512

14.7

35

256

256

4

2

128

512

18.2

36

256

256

4

4

128

512

18.2

37

512

128

1

2

128

512

29.1

38

512

128

2

2

128

512

29.6

39

1024

128

2

2

128

512

39.7

40

1024

256

2

2

128

512

39.7

41

1024

256

1

2

128

512

39.1

42

1024

128

2

4

128

512

39.4

43

1024

256

2

4

128

512

39.8

44

1024

256

4

4

128

512

42.2

 

上表中,各字段含义如下:

Pkt_data_len:报文长度,单位字节

DEF_PKT_BURST:一次发送报文的数量

Nbcore:处理报文的CPU核数目

nb_rxq/txq:报文接收队列,发送队列数目

RTE_TEST_RX_DESC_DEFAULT:收包队列长度

RTE_TEST_TX_DESC_DEFAULT:发包队列长度

Gbps:网卡数据包通过率 Gbit/sec

 

表2 测试环境B下测试结果

序号

Pkt_data_len(不含协议头)

Socket fd数目

Gbps(port1->port3)

1

32

1

5.5

2

32

1(app不绑核)

2.7

3

32

2(两个app分别绑定core2,core3)

5.5

4

64

1

7.3

5

64

2(两个app分别绑定core2,core3)

7.3

6

128

1

10.9

7

128

2(两个app分别绑定core3,core4;

ans绑定core1和core2)

11

8

256

1

17.9

9

512

1

31.8

10

1024

1

35.0

11

2048

1

40.0

12

4096

1

40.0

注:上表中如果没有特别说明ans默认绑定core1 dpdk_udp默认绑定core2

6、分析总结

针对测试环境A,表1中列出了除硬件和软件环境外影响网卡收发包性能的6个因素。分析如下:

1、  数据包大小对网卡速率影响最大,当数据包大小达到1024字节后,速率能接近线速40Gbps。

2、  在数据包大小为64字节时,一次发送报文的数量越多,通过率越大。

3、  处理报文的CPU核数目越多,通过率越大。

4、  在处理报文的CPU核数目较多的情况下增加报文接收发送队列数目能显著提高通过率。

5、  收包队列长度和发包队列长度对网卡速率影响较小,其中收包队列长度为128,发包队列长度为512能满足大部分场景的应用。

针对测试环境B,对表2的分析如下:

1、  数据包大小对速率影响最大,UDP数据包达到2048字节(有效数据字段,不包括协议字段)时达到线速。

2、  APP绑核情况下能提高速率,在32字节小包情况下速率能提升一倍。

3、  采用两个以上app从同一个port不同socket端口进行发数时,与单个app相比对总速率提升没有影响。

4、  Ans绑定1个核和绑定多个核对速率提升影响不大。


7、测试脚本

测试环境A

Test pmdshell:
./testpmd -c 0xfff -l 1-9 -n 4 -- -i start tx_onlychange place:1 testpmd.h #define TXONLY_DEF_PACKET_LEN 642 testpmd.c queueid_t nb_rxq=1; queueid_t nb_txq=13 set nbcore 4 set burst5 testpmd.c #define RTE_TEST_RX_DESC_DEFAULT #define RTE_TEST_TX_DESC_DEFAULT

测试环境B

shellpktgen./usr/dpdk/MLNX_DPDK_16.11_3.0/examples/pktgen-3.4.2/app/app/x86_64-native-linuxapp-gcc/pktgen -l 7,8-9 -n 4 --proc-type auto --log-level 7 --socket-mem 2048,2048 --file-prefix pg -b 80:00.0 -b 80:00.1 -- -T -P --crc-strip -m 8.1 -m 9.3 -f themes/black-yellow.themesset 3 proto udpset 3 src ip 10.1.0.10/24set 3 sport 9999enable 3 garpans./ans -c 0xf -n 4 -- -p 0x2 --config="(1,0,1)"./ans -c 0x6 -n 4 -- -p 0x2 --config="(1,0,1),(1,1,2)"dpdk_udp./dpdk_udp 2

两个DPDK_UDP应用程序代码如下,分别使用port1的不同的socket

/*-*   BSD LICENSE**   Copyright(c) 2015-2017 Ansyun <anssupport@163.com>. All rights reserved.*   All rights reserved.**   Redistribution and use in source and binary forms, with or without*   modification, are permitted provided that the following conditions*   are met:**     * Redistributions of source code must retain the above copyright*       notice, this list of conditions and the following disclaimer.*     * Redistributions in binary form must reproduce the above copyright*       notice, this list of conditions and the following disclaimer in*       the documentation and/or other materials provided with the*       distribution.*     * Neither the name of Ansyun <anssupport@163.com> nor the names of its*       contributors may be used to endorse or promote products derived*       from this software without specific prior written permission.**   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT*   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR*   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT*   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,*   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT*   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,*   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY*   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT*   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE*   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <unistd.h>
#include <sys/times.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <netinet/in.h>
#include <termios.h>
#include <sys/epoll.h>#ifndef __linux__#ifdef __FreeBSD__#include <sys/socket.h>#else#include <net/socket.h>#endif
#endif#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>#include "anssock_intf.h"
#include "ans_errno.h"struct epoll_event events[20];int main(int argc, char *argv[])
{int ret;int i = 0 ;int fd, fd1,recvfd = 0;int epfd;int data_num =0;char send_data[65536];struct timeval start, end;struct sockaddr_in addr_in,addr_in1;  struct sockaddr_in remote_addr;  struct epoll_event event;char recv_buf[2038];int recv_len; int core = -1;if(argc >= 2){core = atoi(argv[1]);printf("affinity to core %d \n", core);/*initialize thread bind cpu*/cpu_set_t cpus;CPU_ZERO(&cpus);CPU_SET((unsigned)core, &cpus);sched_setaffinity(0, sizeof(cpus), &cpus);  }else{printf("no affinity by default \n");}ret = anssock_init(NULL);/* create epoll socket */epfd = anssock_epoll_create(0);fd = anssock_socket(AF_INET, SOCK_DGRAM, 0);memset(&addr_in, 0, sizeof(addr_in));      addr_in.sin_family = AF_INET;  addr_in.sin_port   = htons(4444);  addr_in.sin_addr.s_addr = inet_addr("10.1.0.5"); ret =  anssock_bind(fd, (struct sockaddr *)&addr_in, sizeof(addr_in) );memset(&remote_addr, 0, sizeof(remote_addr));      remote_addr.sin_family = AF_INET;  remote_addr.sin_port   = htons(9999);  remote_addr.sin_addr.s_addr = inet_addr("10.1.0.10");memset(send_data, 0, sizeof(send_data));while(1){anssock_sendto(fd, send_data, 128, 0, (struct sockaddr *)&remote_addr,  sizeof(remote_addr));}anssock_close(fd);anssock_close(epfd);return 0;
}


/*-*   BSD LICENSE**   Copyright(c) 2015-2017 Ansyun <anssupport@163.com>. All rights reserved.*   All rights reserved.**   Redistribution and use in source and binary forms, with or without*   modification, are permitted provided that the following conditions*   are met:**     * Redistributions of source code must retain the above copyright*       notice, this list of conditions and the following disclaimer.*     * Redistributions in binary form must reproduce the above copyright*       notice, this list of conditions and the following disclaimer in*       the documentation and/or other materials provided with the*       distribution.*     * Neither the name of Ansyun <anssupport@163.com> nor the names of its*       contributors may be used to endorse or promote products derived*       from this software without specific prior written permission.**   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT*   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR*   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT*   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,*   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT*   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,*   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY*   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT*   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE*   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <unistd.h>
#include <sys/times.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <netinet/in.h>
#include <termios.h>
#include <sys/epoll.h>#ifndef __linux__#ifdef __FreeBSD__#include <sys/socket.h>#else#include <net/socket.h>#endif
#endif#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>#include "anssock_intf.h"
#include "ans_errno.h"struct epoll_event events[20];int main(int argc, char *argv[])
{int ret;int i = 0 ;int fd, fd1,recvfd = 0;int epfd;int data_num =0;char send_data[1024];struct timeval start, end;struct sockaddr_in addr_in,addr_in1;  struct sockaddr_in remote_addr;  struct epoll_event event;char recv_buf[2038];int recv_len; int core = -1;if(argc >= 2){core = atoi(argv[1]);printf("affinity to core %d \n", core);/*initialize thread bind cpu*/cpu_set_t cpus;CPU_ZERO(&cpus);CPU_SET((unsigned)core, &cpus);sched_setaffinity(0, sizeof(cpus), &cpus);  }else{printf("no affinity by default \n");}ret = anssock_init(NULL);/* create epoll socket */epfd = anssock_epoll_create(0);fd = anssock_socket(AF_INET, SOCK_DGRAM, 0);memset(&addr_in, 0, sizeof(addr_in));      addr_in.sin_family = AF_INET;  addr_in.sin_port   = htons(8888);  addr_in.sin_addr.s_addr = inet_addr("10.1.0.2"); ret =  anssock_bind(fd, (struct sockaddr *)&addr_in, sizeof(addr_in) );memset(&remote_addr, 0, sizeof(remote_addr));      remote_addr.sin_family = AF_INET;  remote_addr.sin_port   = htons(9999);  remote_addr.sin_addr.s_addr = inet_addr("10.1.0.10"); memset(send_data, 0, sizeof(send_data));while(1){anssock_sendto(fd, send_data,  128, 0, (struct sockaddr *)&remote_addr,  sizeof(remote_addr));}anssock_close(fd);anssock_close(epfd);return 0;
}


这篇关于基于DPDK的MellanoxCX4-40G网卡性能测试的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/177471

相关文章

Python如何使用__slots__实现节省内存和性能优化

《Python如何使用__slots__实现节省内存和性能优化》你有想过,一个小小的__slots__能让你的Python类内存消耗直接减半吗,没错,今天咱们要聊的就是这个让人眼前一亮的技巧,感兴趣的... 目录背景:内存吃得满满的类__slots__:你的内存管理小助手举个大概的例子:看看效果如何?1.

Redis中高并发读写性能的深度解析与优化

《Redis中高并发读写性能的深度解析与优化》Redis作为一款高性能的内存数据库,广泛应用于缓存、消息队列、实时统计等场景,本文将深入探讨Redis的读写并发能力,感兴趣的小伙伴可以了解下... 目录引言一、Redis 并发能力概述1.1 Redis 的读写性能1.2 影响 Redis 并发能力的因素二、

Golang中拼接字符串的6种方式性能对比

《Golang中拼接字符串的6种方式性能对比》golang的string类型是不可修改的,对于拼接字符串来说,本质上还是创建一个新的对象将数据放进去,主要有6种拼接方式,下面小编就来为大家详细讲讲吧... 目录拼接方式介绍性能对比测试代码测试结果源码分析golang的string类型是不可修改的,对于拼接字

mysql线上查询之前要性能调优的技巧及示例

《mysql线上查询之前要性能调优的技巧及示例》文章介绍了查询优化的几种方法,包括使用索引、避免不必要的列和行、有效的JOIN策略、子查询和派生表的优化、查询提示和优化器提示等,这些方法可以帮助提高数... 目录避免不必要的列和行使用有效的JOIN策略使用子查询和派生表时要小心使用查询提示和优化器提示其他常

SpringBoot中整合RabbitMQ(测试+部署上线最新完整)的过程

《SpringBoot中整合RabbitMQ(测试+部署上线最新完整)的过程》本文详细介绍了如何在虚拟机和宝塔面板中安装RabbitMQ,并使用Java代码实现消息的发送和接收,通过异步通讯,可以优化... 目录一、RabbitMQ安装二、启动RabbitMQ三、javascript编写Java代码1、引入

Nginx设置连接超时并进行测试的方法步骤

《Nginx设置连接超时并进行测试的方法步骤》在高并发场景下,如果客户端与服务器的连接长时间未响应,会占用大量的系统资源,影响其他正常请求的处理效率,为了解决这个问题,可以通过设置Nginx的连接... 目录设置连接超时目的操作步骤测试连接超时测试方法:总结:设置连接超时目的设置客户端与服务器之间的连接

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

Tomcat高效部署与性能优化方式

《Tomcat高效部署与性能优化方式》本文介绍了如何高效部署Tomcat并进行性能优化,以确保Web应用的稳定运行和高效响应,高效部署包括环境准备、安装Tomcat、配置Tomcat、部署应用和启动T... 目录Tomcat高效部署与性能优化一、引言二、Tomcat高效部署三、Tomcat性能优化总结Tom

C/C++通过IP获取局域网网卡MAC地址

《C/C++通过IP获取局域网网卡MAC地址》这篇文章主要为大家详细介绍了C++如何通过Win32API函数SendARP从IP地址获取局域网内网卡的MAC地址,感兴趣的小伙伴可以跟随小编一起学习一下... C/C++通过IP获取局域网网卡MAC地址通过win32 SendARP获取MAC地址代码#i

C#使用yield关键字实现提升迭代性能与效率

《C#使用yield关键字实现提升迭代性能与效率》yield关键字在C#中简化了数据迭代的方式,实现了按需生成数据,自动维护迭代状态,本文主要来聊聊如何使用yield关键字实现提升迭代性能与效率,感兴... 目录前言传统迭代和yield迭代方式对比yield延迟加载按需获取数据yield break显式示迭