public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/68606] Reduce or disable the static emergency pool for C++ exceptions
Date: Tue, 11 Oct 2022 15:22:52 +0000	[thread overview]
Message-ID: <bug-68606-4-jDGeWTTe6k@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-68606-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68606

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:637e3668fdc17c4e226538fb14f9fab225433d01

commit r13-3234-g637e3668fdc17c4e226538fb14f9fab225433d01
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Oct 5 21:21:54 2022 +0100

    libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606]

    Implement a long-standing request to support tuning the size of the
    emergency buffer for allocating exceptions after malloc fails, or to
    disable that buffer entirely.

    It's now possible to disable the dynamic allocation of the buffer and
    use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool.
    This is a built-time choice that is baked into libstdc++ and so affects
    all code linked against that build of libstdc++.

    The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N
    which is measured in units of sizeof(void*) not bytes. A given exception
    type such as std::system_error depends on the target, so giving a size
    in bytes wouldn't be portable across 16/32/64-bit targets.

    When libstdc++ is configured to use a dynamic buffer, the size of that
    buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES
    environment variable (c.f. PR libstdc++/88264). The number of exceptions
    to reserve space for is controlled by the "glibcxx.eh_pool.obj_count"
    and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be
    able to allocate obj_count exceptions of size obj_size*sizeof(void*) and
    obj_count "dependent" exceptions rethrown by std::rethrow_exception.

    With the ability to tune the buffer size, we can reduce the default pool
    size on 32-bit and 16-bit targets. Most users never need to throw 1kB
    exceptions in parallel from hundreds of threads after malloc is OOM. The
    users who do need that can use the tunables to select larger sizes.

    The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES
    to:
    64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112
    32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104

    Or approximated by configuring with:
    64-bit: --with-libstdcxx-eh-pool-obj-count=252
    32-bit: --with-libstdcxx-eh-pool-obj-count=94

    libstdc++-v3/ChangeLog:

            PR libstdc++/68606
            * Makefile.in: Regenerate.
            * acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro.
            * configure: Regenerate.
            * configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC.
            * crossconfig.m4: Check for secure_getenv.
            * doc/Makefile.in: Regenerate.
            * doc/xml/manual/configure.xml: Document new configure options.
            * doc/xml/manual/evolution.xml: Document addition of tunables.
            * doc/xml/manual/using_exceptions.xml: Document emergency
            buffer and tunables.
            * doc/html/*: Regenerate.
            * include/Makefile.in: Regenerate.
            * libsupc++/Makefile.am: Use EH_POOL_FLAGS.
            * libsupc++/Makefile.in: Regenerate.
            * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units
            of sizeof(void*) not including the ABI's exception header.
            (EMERGENCY_OBJ_COUNT): Define as target-independent calculation
            based on word size.
            (MAX_OBJ_COUNT): Define macro for upper limit on pool size.
            (pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer.
            (pool::buffer_size_in_bytes): New static member function.
            (pool::pool): Parse GLIBCXX_TUNABLES environment variable to set
            pool size at runtime.
            (pool::in_pool): Use std::less<void*> for total order.
            (__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing.
            (__cxa_free_exception, __cxa_free_dependent_exception): Add
            [[unlikely]] attributes.
            * po/Makefile.in: Regenerate.
            * python/Makefile.in: Regenerate.
            * src/Makefile.in: Regenerate.
            * src/c++11/Makefile.in: Regenerate.
            * src/c++17/Makefile.in: Regenerate.
            * src/c++20/Makefile.in: Regenerate.
            * src/c++98/Makefile.in: Regenerate.
            * src/filesystem/Makefile.in: Regenerate.
            * src/libbacktrace/Makefile.in: Regenerate.
            * testsuite/Makefile.in: Regenerate.

  parent reply	other threads:[~2022-10-11 15:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-68606-4@http.gcc.gnu.org/bugzilla/>
2020-05-23 15:45 ` egallager at gcc dot gnu.org
2022-09-28  7:00 ` dumoulin.thibaut at gmail dot com
2022-09-28 14:01 ` rdiezmail-gcc at yahoo dot de
2022-09-28 14:42 ` dumoulin.thibaut at gmail dot com
2022-09-28 15:14 ` rdiezmail-gcc at yahoo dot de
2022-09-28 20:20 ` redi at gcc dot gnu.org
2022-09-28 20:24 ` redi at gcc dot gnu.org
2022-09-29  7:02 ` rguenth at gcc dot gnu.org
2022-09-29  9:31 ` redi at gcc dot gnu.org
2022-09-29 12:24 ` dumoulin.thibaut at gmail dot com
2022-09-29 13:01 ` redi at gcc dot gnu.org
2022-10-07 15:55 ` redi at gcc dot gnu.org
2022-10-11 15:22 ` cvs-commit at gcc dot gnu.org [this message]
2022-10-11 15:25 ` redi 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-68606-4-jDGeWTTe6k@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.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).