public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org, gcc@gcc.gnu.org, fortran@gcc.gnu.org
Subject: libquadmath, glibc, and the Q format flag
Date: Wed, 01 Feb 2023 11:56:42 +0100	[thread overview]
Message-ID: <87lelhzmad.fsf@oldenburg.str.redhat.com> (raw)

I recently discovered that libquadmath registers custom printf callbacks
on load.  As far as I can tell, this is done so that the Q format flag
can be used to print floating point numbers, using format strings such
as "%Qf".  To enable Q flag processing, libquadmath has to register
replacements for all floating point format specifiers (aAeEfFgG).

Unfortunately, this has the side effect that even with out the Q flag,
printing any floating point number enters a generic, slow path in glibc,
prior to the number formatting itself.  The effect is quite pronounced.
For example this admittedly silly benchmarking script

    for i=1,5000000 do
        print(i, i * math.pi)
    end

runs for 5.8 seconds without libquadmath.so.0 loaded on my x86-64
system.  With libquadmath.so.0 from GCC 12 loaded, it runs for 6.3
seconds.

This impacts most (all?) Fortran code on GNU/Linux because libgfortran
depends on libquadmath.

Would it make sense to transplant the implementation of the Q specifier
from libquadmath to glibc, and disable the registration code in
libquadmath if glibc is recent enough?  At least for the targets that
today have float128 support in glibc?

Thanks,
Florian


             reply	other threads:[~2023-02-01 10:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 10:56 Florian Weimer [this message]
2023-02-01 11:07 ` Jakub Jelinek
2023-02-01 11:29   ` Florian Weimer
2023-02-01 11:40     ` Jakub Jelinek

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=87lelhzmad.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=libc-alpha@sourceware.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).