DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: huangdengdui <huangdengdui@huawei.com>
Cc: <dev@dpdk.org>, <konstantin.ananyev@huawei.com>,
	<wathsala.vithanage@arm.com>, <lihuisong@huawei.com>,
	<fengchengwen@huawei.com>, <haijie1@huawei.com>,
	<liuyonglong@huawei.com>
Subject: Re: [PATCH] examples/l3fwd: add option to set refetch offset
Date: Tue, 14 Jan 2025 08:07:52 -0800	[thread overview]
Message-ID: <20250114080752.2615e68d@hermes.local> (raw)
In-Reply-To: <59587382-d90d-4141-936a-6af5fed5c859@huawei.com>

On Tue, 14 Jan 2025 17:22:08 +0800
huangdengdui <huangdengdui@huawei.com> wrote:

> On 2025/1/11 1:20, Stephen Hemminger wrote:
> > This will make it slower for many platforms.
> > GCC will unroll a loop of fixed small size, which is what we want.  
> 
> Do you mean to replace option with a macro?
> But most of prefetch_offset are used with the nb_rx, So using macros is the same as using options.
> 
> const int32_t k = RTE_ALIGN_FLOOR(nb_rx, FWDSTEP);
> for (j = 0; j != k; j += FWDSTEP) {
> 	for (i = 0, pos = j + prefetch_offset;
> 	     i < FWDSTEP && pos < k; i++, pos++)
> 		rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[pos], void *));
> 	processx4_step1(&pkts_burst[j], &dip, &ipv4_flag);
> 	processx4_step2(qconf, dip, ipv4_flag, portid,
> 			&pkts_burst[j], &dst_port[j]);
> 	if (do_step3)
> 		processx4_step3(&pkts_burst[j], &dst_port[j]);
> }
> 
> The option can dynamically adjust the prefetch window, which makes it easier to find the prefetch window for a HW platform.
> So I think it's better to use option.

The tradeoff is that loop unrolling most often is only done on small fix sized loops.
And the cost of a loop with variable small values (branch prediction) is high enough that it 
could make things slower.

Prefetching is a balancing act, and more is not better especially on real workloads.

  reply	other threads:[~2025-01-14 16:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-25  7:53 [PATCH] examples/l3fwd: optimize packet prefetch Dengdui Huang
2024-12-25 21:21 ` Stephen Hemminger
2025-01-08 13:42 ` Konstantin Ananyev
2025-01-09 11:31   ` huangdengdui
2025-01-10  9:37 ` [PATCH] examples/l3fwd: add option to set refetch offset Dengdui Huang
2025-01-10 17:19   ` Stephen Hemminger
2025-01-14  9:23     ` huangdengdui
2025-01-10 17:20   ` Stephen Hemminger
2025-01-14  9:22     ` huangdengdui
2025-01-14 16:07       ` Stephen Hemminger [this message]
2025-01-14 16:11         ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250114080752.2615e68d@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=haijie1@huawei.com \
    --cc=huangdengdui@huawei.com \
    --cc=konstantin.ananyev@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=wathsala.vithanage@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).