DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: "Morten Brørup" <mb@smartsharesystems.com>,
	"Jerin Jacob" <jerinjacobk@gmail.com>, dpdk-dev <dev@dpdk.org>,
	techboard@dpdk.org
Subject: Re: Optimizations are not features
Date: Sun, 5 Jun 2022 09:05:21 -0700	[thread overview]
Message-ID: <20220605090521.5a3bdddf@hermes.local> (raw)
In-Reply-To: <e2f80744-7f19-b193-9941-feb06595fc7a@oktetlabs.ru>

On Sat, 4 Jun 2022 15:51:58 +0300
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru> wrote:

> On 6/4/22 15:19, Morten Brørup wrote:
> >> From: Jerin Jacob [mailto:jerinjacobk@gmail.com]
> >> Sent: Saturday, 4 June 2022 13.10
> >>
> >> On Sat, Jun 4, 2022 at 3:30 PM Andrew Rybchenko
> >> <andrew.rybchenko@oktetlabs.ru> wrote:  
> >>>
> >>> On 6/4/22 12:33, Jerin Jacob wrote:  
> >>>> On Sat, Jun 4, 2022 at 2:39 PM Morten Brørup  
> >> <mb@smartsharesystems.com> wrote:  
> >>>>>
> >>>>> I would like the DPDK community to change its view on compile time  
> >> options. Here is why:  
> >>>>>
> >>>>>
> >>>>>
> >>>>> Application specific performance micro-optimizations like “fast  
> >> mbuf free” and “mbuf direct re-arm” are being added to DPDK and
> >> presented as features.  
> >>>>>
> >>>>>
> >>>>>
> >>>>> They are not features, but optimizations, and I don’t understand  
> >> the need for them to be available at run-time!  
> >>>>>
> >>>>>
> >>>>>
> >>>>> Instead of adding a bunch of exotic exceptions to the fast path of  
> >> the PMDs, they should be compile time options. This will improve
> >> performance by avoiding branches in the fast path, both for the
> >> applications using them, and for generic applications (where the exotic
> >> code is omitted).  
> >>>>
> >>>> Agree. I think, keeping the best of both worlds would be
> >>>>
> >>>> -Enable the feature/optimization as runtime
> >>>> -Have a compile-time option to disable the feature/optimization as  
> >> an override.  
> >>>
> >>> It is hard to find the right balance, but in general compile
> >>> time options are a nightmare for maintenance. Number of
> >>> required builds will grow as an exponent.  
> > 
> > Test combinations are exponential for N features, regardless if N are runtime or compile time options.  
> 
> But since I'm talking about build checks I don't care about exponential
> grows in run time. Yes, testing should care, but it is a separate story.
> 
> >   
> >>> Of course, we can
> >>> limit number of checked combinations, but it will result in
> >>> flow of patches to fix build in other cases.  
> >>
> >> The build breakage can be fixed if we use (2) vs (1)
> >>
> >> 1)
> >> #ifdef ...
> >> My feature
> >> #endif
> >>
> >> 2)
> >> static __rte_always_inline int
> >> rte_has_xyz_feature(void)
> >> {
> >> #ifdef RTE_LIBRTE_XYZ_FEATURE
> >>          return RTE_LIBRTE_XYZ_FEATURE;
> >> #else
> >>          return 0;
> >> #endif
> >> }
> >>
> >> if(rte_has_xyz_feature())) {
> >> My feature code
> >>
> >> }
> >>  
> 
> Jerin, thanks, very good example.
> 
> > I'm not sure all the features can be covered by that, e.g. added fields in structures.  
> 
> +1
> 
> > 
> > Also, I would consider such features "opt in" at compile time only. As such, they could be allowed to break the ABI/API.
> >   
> >>
> >>  
> >>> Also compile time options tend to make code less readable
> >>> which makes all aspects of the development harder.
> >>>
> >>> Yes, compile time is nice for micro optimizations, but
> >>> I have great concerns that it is a right way to go.
> >>>  
> >>>>> Please note that I am only talking about the performance  
> >> optimizations that are limited to application specific use cases. I
> >> think it makes sense to require that performance optimizing an
> >> application also requires recompiling the performance critical
> >> libraries used by it.  
> >>>>>
> >>>>>
> >>>>>
> >>>>> Allowing compile time options for application specific performance  
> >> optimizations in DPDK would also open a path for other optimizations,
> >> which can only be achieved at compile time, such as “no fragmented
> >> packets”, “no attached mbufs” and “single mbuf pool”. And even more
> >> exotic optimizations, such as the “indexed mempool cache”, which was
> >> rejected due to ABI violations – they could be marked as “risky and
> >> untested” or similar, but still be part of the DPDK main repository.  

There is a tradeoff that DPDK has had for several years.

1. For ease of use the DPDK should be available in Linux distributions in
pre-built binary format. In that case any changes in behavior need to be
done at runtime.

2. For performance and size, the DPDK should limit conditional branches
and not include dead code. This is what embedded appliance developers want.

3. For flexibilty, the DPDK should allow every option at the smallest granularity
(often per-packet or per-queue). This allows application to use feature if
available but not be limited to only hardware that supports it.

All of these do conflict. The big problem that I see is that when a feature
that changes the semantic of mbuf is used (no-attach, single pool etc).
It is opening other code to bugs. Therefore I am reluctant to use them;
in real life production 1% performance gain is totally offset by the cost
of .1% more bugs in code run by customers.

It would make my life easier if DPDK supported one set of semantics and
they worked everywhere.  This is what every OS does (Linux, FreeBSD, Windows).
That would mean either all drivers support the feature in all cases or
the feature is never introduced.  What would help this would be a set
of functions that help code do the right thing. Examples in Linux
are skb_linearize(), skb_maypull(), etc.


  parent reply	other threads:[~2022-06-05 16:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-04  9:09 Morten Brørup
2022-06-04  9:33 ` Jerin Jacob
2022-06-04 10:00   ` Andrew Rybchenko
2022-06-04 11:10     ` Jerin Jacob
2022-06-04 12:19       ` Morten Brørup
2022-06-04 12:51         ` Andrew Rybchenko
2022-06-05  8:15           ` Morten Brørup
2022-06-05 16:05           ` Stephen Hemminger [this message]
2022-06-06  9:35           ` Konstantin Ananyev
2022-06-29 20:44             ` Honnappa Nagarahalli
2022-06-30 15:39               ` Morten Brørup
2022-07-03 19:38               ` Konstantin Ananyev
2022-07-04 16:33                 ` Stephen Hemminger
2022-07-04 22:06                   ` Morten Brørup

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=20220605090521.5a3bdddf@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=jerinjacobk@gmail.com \
    --cc=mb@smartsharesystems.com \
    --cc=techboard@dpdk.org \
    /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).