Go to file
Jonathan Wakely 637e3668fd 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.
2022-10-11 16:21:48 +01:00
c++tools
config Daily bump. 2022-09-01 00:17:39 +00:00
contrib Daily bump. 2022-10-08 00:17:29 +00:00
fixincludes Daily bump. 2022-10-08 00:17:29 +00:00
gcc Avoid calling tracer.trailer() twice. 2022-10-11 17:20:10 +02:00
gnattools Daily bump. 2022-09-01 00:17:39 +00:00
gotools Daily bump. 2022-08-31 00:16:45 +00:00
include Daily bump. 2022-09-28 00:17:27 +00:00
INSTALL
intl
libada Daily bump. 2022-08-26 00:16:21 +00:00
libatomic Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libbacktrace Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libcc1 Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libcody
libcpp Daily bump. 2022-10-11 00:17:00 +00:00
libdecnumber Daily bump. 2022-10-08 00:17:29 +00:00
libffi Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libgcc Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libgfortran Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libgo runtime: portable access to sigev_notify_thread_id 2022-09-27 09:30:23 -07:00
libgomp Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libiberty libiberty: Demangling 'M' prefixes 2022-10-11 04:39:50 -07:00
libitm Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libobjc Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
liboffloadmic Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libphobos Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libquadmath Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libsanitizer Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libssp Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
libstdc++-v3 libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606] 2022-10-11 16:21:48 +01:00
libvtv Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
lto-plugin Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
maintainer-scripts Daily bump. 2022-07-29 00:16:21 +00:00
zlib Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2022-10-01 00:18:00 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure Arrange to --disable-shared by default for VxWorks 2022-09-30 10:43:13 +00:00
configure.ac Arrange to --disable-shared by default for VxWorks 2022-09-30 10:43:13 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4 Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS Update my address and DCO entry in MAINTAINERS file 2022-09-26 09:14:55 -06:00
Makefile.def Makefile.def: drop remnants of unused libelf 2022-08-18 09:37:09 +01:00
Makefile.in Makefile.def: drop remnants of unused libelf 2022-08-18 09:37:09 +01:00
Makefile.tpl Makefile.def: drop remnants of unused libelf 2022-08-18 09:37:09 +01:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.