All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever III <chuck.lever@oracle.com>
To: Neil Brown <neilb@suse.de>
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: Mon, 3 Jul 2023 13:56:19 +0000	[thread overview]
Message-ID: <F0F2C0F7-3F73-4713-BB37-661463646CC5@oracle.com> (raw)
In-Reply-To: <168835968730.8939.17203263812842647260@noble.neil.brown.name>



> On Jul 3, 2023, at 12:48 AM, NeilBrown <neilb@suse.de> wrote:
> 
> On Fri, 30 Jun 2023, Chuck Lever wrote:
>> Here's something just for fun. I've converted nfsd4_encode_fattr4()
>> to use a bitmask loop, calling an encode helper for each attribute
>> to be encoded. Rotten tomatoes and gold stars are both acceptible.
> 
> Tomatoes or stars .... it is a hard choice :-)
> 
> I wonder what the compiler does with this code.
> If it unrolls the loop and inlines the functions - which it probably can
> do as the array of pointers is declared const - you end up with much the
> same result as the current code.
> 
> And I wonder where the compiler puts the code in each conditional now.
> If it assumes an if() is unlikely, then it would all be out-of-line
> which sounds like part of your goal (or maybe just a nice-to-have).
> 
> If the compiler does, or can be convinced to, do the unroll and inline
> and unlikely optimisations, then I think I'd give this a goal star.
> 
> 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.

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.


> 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.


> 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.

I appreciate the review!


--
Chuck Lever



  reply	other threads:[~2023-07-03 13:57 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 [this message]
2023-07-03 21:33     ` NeilBrown
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=F0F2C0F7-3F73-4713-BB37-661463646CC5@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=cel@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    /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.