All of lore.kernel.org
 help / color / mirror / Atom feed
From: "NeilBrown" <neilb@suse.de>
To: "Chuck Lever III" <chuck.lever@oracle.com>
Cc: "Chuck Lever" <cel@kernel.org>,
	"Linux NFS Mailing List" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH RFC 0/4] Encode NFSv4 attributes via a branch table
Date: Tue, 04 Jul 2023 07:33:38 +1000	[thread overview]
Message-ID: <168842001897.8939.938340124592787737@noble.neil.brown.name> (raw)
In-Reply-To: <F0F2C0F7-3F73-4713-BB37-661463646CC5@oracle.com>

On Mon, 03 Jul 2023, Chuck Lever III wrote:
> 
> > On Jul 3, 2023, at 12:48 AM, NeilBrown <neilb@suse.de> wrote:
> > 
> > I guess in practice some of the attributes are "likely" and many are
> > "unlikely".
> 
> This is absolutely the case.
> 
> My first attempt at optimizing nfsd4_encode_fattr() was to build
> a miniature version that handled just the frequently-requested
> combinations of attributes. It made very little difference.

My understanding of the effect of these code-movement optimisations is
that they affect whole-system performance rather than micro-benchmarks. 
So they are quite hard to measure.
Modern CPUs are quite good at predicting code flow, so the benefit of
code movement is not a reduction in pipeline stalls, but a reduction in
cache usage.  The latter affects the whole system more-or-less equally.


> 
> The conclusions that I drew from that are:
> 
> - The number of conditional branches in here doesn't seem to be
>   the costly part of encode_fattr().
> 
> - The frequently-requested attributes are expensive to process
>   for some reason. Size is easy, but getting the user and
>   group are not as quick as I would have hoped.
> 
> - It's not the efficiency of encode_fattr() that is the issue,
>   it's the frequency of its use. That's something the server
>   can't do much about.

There probably needs a protocol revision to improve this.  I imagine a
GETATTR request including a CTIME value with the implication that if the
CTIME hasn't changed, then there is no need to return any attributes.

> 
> 
> > With the current code we could easily annotate that if we
> > wanted to and thought (or measured) there was any value.  With the
> > looping code we cannot really annotate the likelihood of each.
> 
> Nope, likelihood annotation isn't really possible with a bitmask
> loop. But my understanding is that unlikely() means really
> really really unlikely, as in "this code is an error case that
> is almost never used". And that's not actually the case for most
> of these attributes.

My understanding of unlikely() (which is largely compatible with yours)
is that it tells the compile to pessimise code dependant on the
condition being true.  Or more accurately: when there is an optimisation
trade off between code for the 'true' case and any other code, preference
the other code.
So it is definitely good to say errors are unlikely, because there is no
need to optimise for them.  You might also say a fast-path condition is
likely() because that path is more worthy of optimisation.

> 
> 
> > The code-generation idea is intriguing.  Even if we didn't reach that
> > goal, having the code highly structured as though it were auto-generated
> > would be no bad thing.
> 
> Maybe it just calms my yearning for an ordered universe to deal
> with these attributes in the same way that we deal with COMPOUND
> operations.

There are worse reasons for refactoring code:-)

Thanks,
NeilBrown

> 
> I appreciate the review!
> 
> 
> --
> Chuck Lever
> 
> 
> 


  reply	other threads:[~2023-07-03 21:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30  1:34 [PATCH RFC 0/4] Encode NFSv4 attributes via a branch table Chuck Lever
2023-06-30  1:34 ` [PATCH RFC 1/4] NFSD: Add struct nfsd4_fattr_args Chuck Lever
2023-06-30  1:34 ` [PATCH RFC 2/4] NFSD: Encode attributes in WORD0 using a bitmask loop Chuck Lever
2023-06-30  1:34 ` [PATCH RFC 3/4] NFSD: Encode attributes in WORD1 " Chuck Lever
2023-06-30  1:35 ` [PATCH RFC 4/4] NFSD: Encode attributes in WORD2 " Chuck Lever
2023-07-03  4:48 ` [PATCH RFC 0/4] Encode NFSv4 attributes via a branch table NeilBrown
2023-07-03 13:56   ` Chuck Lever III
2023-07-03 21:33     ` NeilBrown [this message]
2023-07-03 23:05       ` Chuck Lever III

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=168842001897.8939.938340124592787737@noble.neil.brown.name \
    --to=neilb@suse.de \
    --cc=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.