public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug stdio/21127] printf functions can take much memory with %g when the format precision is large
Date: Mon, 06 May 2024 11:42:17 +0000	[thread overview]
Message-ID: <bug-21127-131-tx6Z76HD5d@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-21127-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=21127

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-05-06
                 CC|                            |carlos at redhat dot com
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Carlos O'Donell <carlos at redhat dot com> ---
For modern glibc (last 2 years) the digit printing goes through
__vfprintf_internal, and uses the __printf_buffer code that Florian Weimer
added in 2022.

The __printf_buffer code manages to print the test case without using more than
a ~295MiB of heap at peak usage to compute the internal result.

The test is still quite slow because we need to use multi-precision digits to
compute the result e.g. __printf_fp_buffer_1() -> hack_digit().

As we cross from 10.5 -> 9.5 things change. Internally scalesize drops to zero
and the fracsize goes up to 2, this is the cut-point in the internal
algorithm's optimization.

I can confirm that this is the reason you see the transition in performance,
and I can confirm that it takes a lot of memory to compute a correct answer to
the number of requested digits.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

       reply	other threads:[~2024-05-06 11:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-21127-131@http.sourceware.org/bugzilla/>
2024-05-06 11:42 ` carlos at redhat dot com [this message]
2024-05-07 17:19 ` jsm28 at gcc dot gnu.org

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=bug-21127-131-tx6Z76HD5d@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@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).