mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] select: do_pollfd: add unlikely branch hint return path
Date: Wed, 9 Apr 2025 16:23:28 +0100	[thread overview]
Message-ID: <1862386e-fca2-470e-929c-0205a56c0f2f@gmail.com> (raw)
In-Reply-To: <llt32u2qdjyu3giwhxesrahsh5a2ks6behzzkjky7fe7k6xync@pvixqbom73il>


[-- Attachment #1.1.1: Type: text/plain, Size: 1925 bytes --]

On 09/04/2025 16:18, Mateusz Guzik wrote:
> On Wed, Apr 09, 2025 at 03:31:38PM +0100, Colin Ian King wrote:
>> Adding an unlikely() hint on the fd < 0 comparison return path improves
>> run-time performance of the mincore system call. gcov based coverage
>> analysis shows that this path return path is highly unlikely.
>>
>> Benchmarking on an Debian based Intel(R) Core(TM) Ultra 9 285K with
>> a 6.15-rc1 kernel and a poll of 1024 file descriptors with zero timeout
>> shows an call reduction from 32818 ns down to 32635 ns, which is a ~0.5%
>> performance improvement.
>>
>> Results based on running 25 tests with turbo disabled (to reduce clock
>> freq turbo changes), with 30 second run per test and comparing the number
>> of poll() calls per second. The % standard deviation of the 25 tests
>> was 0.08%, so results are reliable.
>>
> 
> I don't think adding a branch hint warrants benchmarking of the sort.
> 
> Instead the thing to do is to check if the prediction matches real world
> uses.
> 
> While it is impossible to check this for all programs out there, it
> should not be a significant time investment to look to check some of the
> popular ones out there. Normally I would do it with bpftrace, but this
> comes from a user-backed area instead of func args, so involved hackery
> may be needed which is not warranted the change. Perhaps running strace
> on a bunch of network progs would also do it (ssh, browser?).
> 
> I have to say I did not even know one can legally pass a fd < 0 to poll
> and I never seen it in action, so I don't expect many users. ;)

I did check this based on gcov coverage (mentioned in the commit 
message) and this is based on running gcov data from running stress-ng 
and kernel builds and I've been looking for branch hint performance wins
based on the top 250 if statements that are not already hinted using 
likely/unlikely.

Colin


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 4901 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2025-04-09 15:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 14:31 Colin Ian King
2025-04-09 15:18 ` Mateusz Guzik
2025-04-09 15:23   ` Colin King (gmail) [this message]
2025-04-09 15:30     ` Mateusz Guzik

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=1862386e-fca2-470e-929c-0205a56c0f2f@gmail.com \
    --to=colin.i.king@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®