binutils-gdb/gdbsupport
Richard Bunt 33ae45434d gdb: Enable early init of thread pool size
This commit enables the early initialization commands (92e4e97a9f) to
modify the number of threads used by gdb's thread pool.

The motivation here is to prevent gdb from spawning a detrimental number
of threads on many-core systems under environments with restrictive
ulimits.

With gdb before this commit, the thread pool takes the following sizes:

1. Thread pool size is initialized to 0.

2. After the maintenance commands are defined, the thread pool size is
set to the number of system cores (if it has not already been set).

3. Using early initialization commands, the thread pool size can be
changed using "maint set worker-threads".

4. After the first prompt, the thread pool size can be changed as in the
previous step.

Therefore after step 2. gdb has potentially launched hundreds of threads
on a many-core system.

After this change, step 2 and 3 are reversed so there is an opportunity
to set the required number of threads without needing to default to the
number of system cores first.

There does exist a configure option (added in 261b07488b) to disable
multithreading, but this does not allow for an already deployed gdb to
be configured.

Additionally, the default number of worker threads is clamped at eight
to control the number of worker threads spawned on many-core systems.
This value was chosen as testing recorded on bugzilla issue 29959
indicates that parallel efficiency drops past this point.

GDB built with GCC 13.

No test suite regressions detected. Compilers: GCC, ACfL, Intel, Intel
LLVM, NVHPC; Platforms: x86_64, aarch64.

The scenario that interests me the most involves preventing GDB from
spawning any worker threads at all. This was tested by counting the
number of clones observed by strace:

    strace -e clone,clone3 gdb/gdb -q \
    --early-init-eval-command="maint set worker-threads 0" \
    -ex q ./gdb/gdb |& grep --count clone

The new test relies on "gdb: install CLI uiout while processing early
init files" developed by Andrew Burgess. This patch will need pushing
prior to this change.

The clamping was tested on machines with both 16 cores and a single
core.  "maint show worker-threads" correctly reported eight and one
respectively.

Approved-By: Tom Tromey <tom@tromey.com>
2023-12-04 14:23:17 +00:00
..
.dir-locals.el Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
.gitattributes
acinclude.m4
aclocal.m4 Finalized intl-update patches 2023-11-15 12:53:04 +00:00
agent.cc Do not cast away const in agent_run_command 2023-02-14 09:01:18 -07:00
agent.h Do not cast away const in agent_run_command 2023-02-14 09:01:18 -07:00
alt-stack.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
array-view.h Enable some C++14 code in array-view.h 2023-11-29 14:29:44 -07:00
ax.def Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
block-signals.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
break-common.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
btrace-common.cc Use C++17 [[fallthrough]] attribute 2023-11-29 14:29:43 -07:00
btrace-common.h gdb: c++ify btrace_target_info 2023-09-11 06:15:52 +00:00
buildargv.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
byte-vector.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
ChangeLog-2020-2021
check-defines.el Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
cleanups.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
cleanups.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
common-debug.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
common-debug.h gdb: Replace gdb::optional with std::optional 2023-11-21 11:52:35 +00:00
common-defs.h Remove EXTERN_C and related defines 2023-11-06 20:31:12 -07:00
common-exceptions.cc [gdb] Fix typos 2023-06-03 22:43:57 +02:00
common-exceptions.h [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion 2023-08-17 10:41:34 +02:00
common-gdbthread.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
common-inferior.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
common-inferior.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
common-regcache.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
common-regcache.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
common-types.h Move unrelocated_addr to common-types.h 2023-06-05 09:59:18 -06:00
common-utils.cc gdb: Fix building with latest libc++ 2023-04-29 00:35:11 -07:00
common-utils.h gdb: Use std::string_view instead of gdb::string_view 2023-11-21 11:52:36 +00:00
common.m4 Move -lsocket check to common.m4 2023-10-12 18:23:13 -06:00
compiler-type.m4 Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
config.in Finalized intl-update patches 2023-11-15 12:53:04 +00:00
configure Switch to -Wimplicit-fallthrough=5 2023-11-29 14:29:43 -07:00
configure.ac gdb/gdbsupport/gdbserver: Require c++17 2023-10-28 19:25:34 +00:00
create-version.sh Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
def-vector.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
default-init-alloc.h [gdb/build, c++20] Handle deprecated std::allocator::construct 2023-08-17 10:41:34 +02:00
eintr.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
enum-flags.h [gdb] Fix typos 2023-06-03 22:43:57 +02:00
environ.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
environ.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
errors.cc Introduce throw_winerror_with_name 2023-11-27 12:55:14 -07:00
errors.h Introduce throw_winerror_with_name 2023-11-27 12:55:14 -07:00
event-loop.cc gdb: Replace gdb::optional with std::optional 2023-11-21 11:52:35 +00:00
event-loop.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
event-pipe.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
event-pipe.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
fileio.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
fileio.h gdb, gdbserver, gdbsupport: fix whitespace issues 2023-03-09 16:32:00 -05:00
filestuff.cc gdb: Replace gdb::optional with std::optional 2023-11-21 11:52:35 +00:00
filestuff.h gdb: Replace gdb::optional with std::optional 2023-11-21 11:52:35 +00:00
filtered-iterator.h gdbsupport: Replace gdb::invoke_result with std::invoke_result 2023-11-21 11:52:36 +00:00
format.cc Use C++17 [[fallthrough]] attribute 2023-11-29 14:29:43 -07:00
format.h gdb: Use std::string_view instead of gdb::string_view 2023-11-21 11:52:36 +00:00
forward-scope-exit.h gdb: Replace gdb::optional with std::optional 2023-11-21 11:52:35 +00:00
function-view.h gdbsupport: Replace gdb::invoke_result with std::invoke_result 2023-11-21 11:52:36 +00:00
gdb_assert.h Remove gdb_static_assert 2023-11-29 14:29:44 -07:00
gdb_binary_search.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_file.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_locale.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_obstack.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_obstack.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_proc_service.h Remove EXTERN_C and related defines 2023-11-06 20:31:12 -07:00
gdb_ref_ptr.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_regex.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_regex.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_select.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_setjmp.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_signals.h [gdb] Fix typos 2023-06-03 22:43:57 +02:00
gdb_splay_tree.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_sys_time.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_tilde_expand.cc gdb, gdbserver, gdbsupport: fix whitespace issues 2023-03-09 16:32:00 -05:00
gdb_tilde_expand.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_unique_ptr.h gdb: Use C++17's std::make_unique instead of gdb::make_unique 2023-11-21 11:52:35 +00:00
gdb_unlinker.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_vecs.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_vecs.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_wait.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb_wait.h Remove explanatory comments from includes 2023-09-20 11:45:16 -06:00
gdb-checked-static-cast.h gdbsupport: add support for references to checked_static_cast 2023-05-24 14:53:53 -04:00
gdb-dlfcn.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb-dlfcn.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb-hashtab.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb-hashtab.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb-safe-ctype.h gdb: Fix building with latest libc++ 2023-04-29 00:35:11 -07:00
gdb-sigmask.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb-xfree.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
hash_enum.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
host-defs.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
intrusive_list.h gdbsupport: use "reference" and "pointer" type aliases in intrusive_list 2023-10-19 10:57:51 -04:00
iterator-range.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
job-control.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
job-control.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
Makefile.am Finalized intl-update patches 2023-11-15 12:53:04 +00:00
Makefile.in Finalized intl-update patches 2023-11-15 12:53:04 +00:00
netstuff.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
netstuff.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
new-op.cc Rely on C++17 <new> in new-op.cc 2023-11-29 14:29:44 -07:00
next-iterator.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
observable.h gdb, gdbserver, gdbsupport: fix whitespace issues 2023-03-09 16:32:00 -05:00
offset-type.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
packed.h Remove gdb_static_assert 2023-11-29 14:29:44 -07:00
parallel-for.h gdbsupport: Replace gdb::invoke_result with std::invoke_result 2023-11-21 11:52:36 +00:00
pathstuff.cc [gdb] Fix typos 2023-06-03 22:43:57 +02:00
pathstuff.h Remove gdb_static_assert 2023-11-29 14:29:44 -07:00
poison.h [gdb/build, c++20] Stop using deprecated is_pod 2023-08-17 10:41:34 +02:00
preprocessor.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
print-utils.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
print-utils.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
ptid.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
ptid.h Fix build failure with GCC 4.8 2023-09-15 10:36:15 -06:00
ptrace.m4 Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
range-chain.h gdb: Replace gdb::optional with std::optional 2023-11-21 11:52:35 +00:00
README
refcounted-object.h [gdb] Fix segfault in for_each_block, part 1 2023-11-28 10:31:25 +01:00
reference-to-pointer-iterator.h [gdb] Fix typos 2023-06-03 22:43:57 +02:00
rsp-low.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
rsp-low.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
run-time-clock.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
run-time-clock.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
safe-iterator.h gdbsupport: Replace gdb::invoke_result with std::invoke_result 2023-11-21 11:52:36 +00:00
safe-strerror.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
scope-exit.h Rely on copy elision in scope-exit.h 2023-11-29 14:29:44 -07:00
scoped_fd.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
scoped_ignore_signal.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
scoped_ignore_sigttou.h gdb: Replace gdb::optional with std::optional 2023-11-21 11:52:35 +00:00
scoped_mmap.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
scoped_mmap.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
scoped_restore.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
search.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
search.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
selftest.cc gdbsupport: record and print failed selftest names 2023-11-03 14:25:59 -04:00
selftest.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
selftest.m4 Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
signals-state-save-restore.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
signals-state-save-restore.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
signals.cc [gdb] Fix typos 2023-06-03 22:43:57 +02:00
symbol.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
tdesc.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
tdesc.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
thread-pool.cc gdb: Enable early init of thread pool size 2023-12-04 14:23:17 +00:00
thread-pool.h gdb: Enable early init of thread pool size 2023-12-04 14:23:17 +00:00
traits.h Use C++17 void_t 2023-11-29 14:29:44 -07:00
underlying.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
valid-expr.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
version.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
warning.m4 Switch to -Wimplicit-fallthrough=5 2023-11-29 14:29:43 -07:00
x86-xstate.h x86: Remove X86_XSTATE_SIZE and related constants. 2023-08-28 14:18:19 -07:00
xml-utils.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
xml-utils.h Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00

This is a helper library that is used by gdb and gdbserver.

To send patches, follow the gdb patch submission instructions in
../gdb/CONTRIBUTE.  For maintainers, see ../gdb/MAINTAINERS.