From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CB03D45D7C; Fri, 22 Nov 2024 12:01:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3FFD43252; Fri, 22 Nov 2024 12:01:28 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 47D2F40278 for ; Fri, 22 Nov 2024 12:01:26 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XvsYd3pXrzqSlw; Fri, 22 Nov 2024 18:59:33 +0800 (CST) Received: from kwepemf100006.china.huawei.com (unknown [7.202.181.220]) by mail.maildlp.com (Postfix) with ESMTPS id 7252D18007C; Fri, 22 Nov 2024 19:01:24 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by kwepemf100006.china.huawei.com (7.202.181.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 22 Nov 2024 19:01:22 +0800 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.039; Fri, 22 Nov 2024 12:01:14 +0100 From: Konstantin Ananyev To: haijie , "dev@dpdk.org" , "thomas@monjalon.net" , "ferruh.yigit@amd.com" , =?iso-8859-1?Q?Morten_Br=F8rup?= , Fengchengwen , "lihuisong (C)" CC: haijie , huangdengdui Subject: RE: [PATCH] examples/l3fwd: fix Tx performance deteriorate Thread-Topic: [PATCH] examples/l3fwd: fix Tx performance deteriorate Thread-Index: AQHbPK4LNLW2CeYr7kax6lhctQju/bLDIYIA Date: Fri, 22 Nov 2024 11:01:14 +0000 Message-ID: References: <20241122071336.18470-1-haijie1@huawei.com> In-Reply-To: <20241122071336.18470-1-haijie1@huawei.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.206.138.73] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > The application send packets only when the buffer is full, or the > buffer is empty and the number of packets to be sent extends half > of the buffer. >=20 > The change of MAX_PKT_BURST increases TX buffer size, while the > default size of local cache on each lcore is 256, which not greater > than the limit of transmitting. That would make the mbuf not on the > local cache be frequently used and the performance deteriorates. >=20 > This problem can be solved by making the TX threshold smaller than > the local cache size. For example, use the '--mbcache' parameter to > make the local cache greater. This patch optimizes the default > performance by lowering TX threshold. In commit: examples/l3fwd: add option to set Rx burst size you introduced new global=20 uint32_t nb_pkt_per_burst; Why not to use it for both (rx and tx) paths? Or if necessary introduce another one for tx, so we'll have: uint32_t nb_rx_pkt_per_burst, nb_tx_pkt_per_burst,; To me that is much better then create some hardcoded and implicit thresholds. =20 > Fixes: d5c4897ecfb2 ("examples/l3fwd: add option to set Rx burst size") >=20 > Signed-off-by: Jie Hai > --- > examples/l3fwd/l3fwd.h | 8 +++++--- > examples/l3fwd/l3fwd_common.h | 6 +++--- > 2 files changed, 8 insertions(+), 6 deletions(-) >=20 > diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h > index 0cce3406ee7d..a01fecd51261 100644 > --- a/examples/l3fwd/l3fwd.h > +++ b/examples/l3fwd/l3fwd.h > @@ -35,7 +35,7 @@ > /* > * Try to avoid TX buffering if we have at least MAX_TX_BURST packets to= send. > */ > -#define MAX_TX_BURST (MAX_PKT_BURST / 2) > +#define MAX_TX_BURST DEFAULT_PKT_BURST >=20 > #define NB_SOCKETS 8 >=20 > @@ -57,6 +57,8 @@ > #define L3FWD_HASH_ENTRIES (1024*1024*1) > #endif >=20 > +static_assert(MAX_TX_BURST <=3D MAX_PKT_BURST, "MAX_TX_BURST should be a= t most MAX_PKT_BURST"); > + > struct parm_cfg { > const char *rule_ipv4_name; > const char *rule_ipv6_name; > @@ -152,8 +154,8 @@ send_single_packet(struct lcore_conf *qconf, > len++; >=20 > /* enough pkts to be sent */ > - if (unlikely(len =3D=3D MAX_PKT_BURST)) { > - send_burst(qconf, MAX_PKT_BURST, port); > + if (unlikely(len =3D=3D MAX_TX_BURST)) { > + send_burst(qconf, MAX_TX_BURST, port); > len =3D 0; > } >=20 > diff --git a/examples/l3fwd/l3fwd_common.h b/examples/l3fwd/l3fwd_common.= h > index d94e5f135791..3f504dc0a552 100644 > --- a/examples/l3fwd/l3fwd_common.h > +++ b/examples/l3fwd/l3fwd_common.h > @@ -71,7 +71,7 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port,= struct rte_mbuf *m[], > * If TX buffer for that queue is empty, and we have enough packets, > * then send them straightway. > */ > - if (num >=3D MAX_TX_BURST && len =3D=3D 0) { > + if (num >=3D MAX_TX_BURST / 2 && len =3D=3D 0) { > n =3D rte_eth_tx_burst(port, qconf->tx_queue_id[port], m, num); > if (unlikely(n < num)) { > do { > @@ -112,9 +112,9 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t por= t, struct rte_mbuf *m[], > len +=3D n; >=20 > /* enough pkts to be sent */ > - if (unlikely(len =3D=3D MAX_PKT_BURST)) { > + if (unlikely(len > MAX_TX_BURST)) { >=20 > - send_burst(qconf, MAX_PKT_BURST, port); > + send_burst(qconf, len, port); >=20 > /* copy rest of the packets into the TX buffer. */ > len =3D num - n; > -- > 2.22.0