public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Sergey Bugaev <bugaevc@gmail.com>
To: "Cristian Rodríguez" <cristian@rodriguez.im>,
	"Samuel Thibault" <samuel.thibault@gnu.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 3/3] Mark various cold functions as __COLD
Date: Tue, 2 May 2023 09:45:09 +0300	[thread overview]
Message-ID: <CAN9u=HfFsKVP23NFTTUdBeUX1jfvbh86oNrtFcz4=9j4i0aeTA@mail.gmail.com> (raw)
In-Reply-To: <20230501215426.ihg3dpichaxtecvz@begin>

Hello,

On Tue, May 2, 2023 at 12:54 AM Samuel Thibault <samuel.thibault@gnu.org> wrote:
> Cristian Rodríguez, le lun. 01 mai 2023 17:52:17 -0400, a ecrit:
> > abort() and all the function wrappers called by assert on failure are also
> > cold.
>
> Indeed, most __noreturn__ functions a probably worth having a look at.

I was under the impression that noreturn functions automatically get
treated similarly to ones with an explicit attribute((cold)). (But I
still marked some, but not all -- fairly arbitrarily -- noreturn
functions __COLD in this patch...)

From taking a closer look now, I see that while the generated assembly
instructions may be similar/identical, it's not strictly the same
thing: with attribute((cold)) the cold path code goes into
.text.unlikely, and without it's still in the regular .text. So
applying __COLD should be beneficial indeed. I will send a follow-up
patch; thank you for pointing this out and making me double-check :)

Is there some sort of a benchmark where we could see whether this
makes any difference? (Not calling the cold function in a loop, of
course -- that is likely to regress, in fact -- but rather calling a
hot function in a loop and benefitting from the cold path not getting
in the way, improved code locality etc.)

Sergey

  reply	other threads:[~2023-05-02  6:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-29 13:12 [PATCH 1/3] cdefs.h: Define __COLD Sergey Bugaev
2023-04-29 13:12 ` [PATCH 2/3] hurd: Mark error functions as __COLD Sergey Bugaev
2023-04-29 15:04   ` Samuel Thibault
2023-04-29 13:12 ` [PATCH 3/3] Mark various cold " Sergey Bugaev
2023-04-29 15:06   ` Samuel Thibault
2023-05-01 16:15     ` Siddhesh Poyarekar
2023-05-01 17:38       ` Samuel Thibault
2023-05-01 21:52   ` Cristian Rodríguez
2023-05-01 21:54     ` Samuel Thibault
2023-05-02  6:45       ` Sergey Bugaev [this message]
2023-04-29 13:20 ` [PATCH] cdefs.h: Define __COLD Sergey Bugaev
2023-04-29 15:02   ` Samuel Thibault

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='CAN9u=HfFsKVP23NFTTUdBeUX1jfvbh86oNrtFcz4=9j4i0aeTA@mail.gmail.com' \
    --to=bugaevc@gmail.com \
    --cc=cristian@rodriguez.im \
    --cc=libc-alpha@sourceware.org \
    --cc=samuel.thibault@gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).