* [review] Add maint set/show worker-threads
@ 2019-10-20 3:55 Tom Tromey (Code Review)
2019-10-20 6:31 ` Eli Zaretskii
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-20 3:55 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Add maint set/show worker-threads
This adds maint commands to control the number of worker threads that
gdb can use.
gdb/ChangeLog
2019-10-19 Tom Tromey <tom@tromey.com>
* NEWS: Add entry.
* maint.c (_initialize_maint_cmds): Add "worker-threads" maint
commands. Call update_thread_pool_size.
(update_thread_pool_size, maintenance_set_worker_threads): New
functions.
(n_worker_threads): New global.
gdb/doc/ChangeLog
2019-10-19 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document new maint
commands.
Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
---
M gdb/ChangeLog
M gdb/NEWS
M gdb/doc/ChangeLog
M gdb/doc/gdb.texinfo
M gdb/maint.c
5 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f4ec322..7be0051 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * NEWS: Add entry.
+ * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
+ commands. Call update_thread_pool_size.
+ (update_thread_pool_size, maintenance_set_worker_threads): New
+ functions.
+ (n_worker_threads): New global.
+
2019-10-19 Christian Biesinger <cbiesinger@google.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/NEWS b/gdb/NEWS
index 25e67e4..7c98c14 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -134,6 +134,13 @@
set style highlight intensity VALUE
Control the styling of highlightings.
+maint set worker-threads
+maint show worker-threads
+ Control the number of worker threads that can be used by GDB. The
+ default is "unlimited", which lets GDB choose a number that is
+ reasonable. Currently worker threads are only used when demangling
+ the names of linker symbols.
+
maint set test-settings KIND
maint show test-settings KIND
A set of commands used by the testsuite for exercising the settings
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 26f858f..175fc98 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * gdb.texinfo (Maintenance Commands): Document new maint
+ commands.
+
2019-10-07 Tom de Vries <tdevries@suse.de>
* gdb.texinfo: Fix typo.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 1208e4f..3219e68 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37683,6 +37683,21 @@
If DWARF frame unwinders are not supported for a particular target
architecture, then enabling this flag does not cause them to be used.
+
+@kindex maint set worker-threads
+@kindex maint show worker-threads
+@item maint set worker-threads
+@item maint show worker-threads
+Control the number of worker threads that may be used by @value{GDBN}.
+On capable hosts, @value{GDBN} may use multiple threads to speed up
+certain CPU-intensive operations, such as demangling symbol names.
+While the number of threads used by @value{GDBN} may vary, this
+command can be used to set an upper bound on this number. The default
+is @code{unlimited}, which lets @value{GDBN} choose a reasonable
+number. Note that this only controls worker threads started by
+@value{GDBN} itself; libraries used by @value{GDBN} may start threads
+of their own.
+
@kindex maint set profile
@kindex maint show profile
@cindex profiling GDB
diff --git a/gdb/maint.c b/gdb/maint.c
index ec9f4ab..a53b3be 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -46,6 +46,10 @@
#include "cli/cli-setshow.h"
#include "cli/cli-cmds.h"
+#if CXX_STD_THREAD
+#include "gdbsupport/thread-pool.h"
+#endif
+
static void maintenance_do_deprecate (const char *, int);
/* Access the maintenance subcommands. */
@@ -840,6 +844,37 @@
error (_("Profiling support is not available on this system."));
}
#endif
+
+static int n_worker_threads = -1;
+
+/* Update the thread pool for the desired number of threads. */
+static void
+update_thread_pool_size ()
+{
+#if CXX_STD_THREAD
+ int n_threads = n_worker_threads;
+
+ if (n_threads < 0)
+ {
+ n_threads = std::thread::hardware_concurrency ();
+ if (n_threads == 0)
+ {
+ /* Meh. */
+ n_threads = 2;
+ }
+ }
+
+ gdb::thread_pool::g_thread_pool.set_thread_count (n_threads);
+#endif
+}
+
+static void
+maintenance_set_worker_threads (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_thread_pool_size ();
+}
+
\f
/* If true, display time usage both at startup and for each command. */
@@ -1312,4 +1347,17 @@
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_unlimited_cmd ("worker-threads",
+ class_maintenance,
+ &n_worker_threads, _("\
+Set the number of worker threads GDB can use."), _("\
+Set the number of worker threads GDB can use."), _("\
+GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
+such as demangling symbol names."),
+ maintenance_set_worker_threads, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+
+ update_thread_pool_size ();
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [review] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
@ 2019-10-20 6:31 ` Eli Zaretskii
2019-10-20 20:55 ` [review v2] " Tom Tromey (Code Review)
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2019-10-20 6:31 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches
> Date: Sat, 19 Oct 2019 23:55:13 -0400
> From: "Tom Tromey (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
>
> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
> ......................................................................
>
> Add maint set/show worker-threads
>
> This adds maint commands to control the number of worker threads that
> gdb can use.
>
> gdb/ChangeLog
> 2019-10-19 Tom Tromey <tom@tromey.com>
>
> * NEWS: Add entry.
> * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
> commands. Call update_thread_pool_size.
> (update_thread_pool_size, maintenance_set_worker_threads): New
> functions.
> (n_worker_threads): New global.
>
> gdb/doc/ChangeLog
> 2019-10-19 Tom Tromey <tom@tromey.com>
>
> * gdb.texinfo (Maintenance Commands): Document new maint
> commands.
I think this was already reviewed on the list, and I approved the
documentation changes at that time (this post doesn't say it is a new
version of the patch, so maybe I'm missing something). But in any
case, you have my approval for the documentation parts.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v2] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
2019-10-20 6:31 ` Eli Zaretskii
@ 2019-10-20 20:55 ` Tom Tromey (Code Review)
2019-10-30 23:00 ` [review v3] " Tom Tromey (Code Review)
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-20 20:55 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Add maint set/show worker-threads
This adds maint commands to control the number of worker threads that
gdb can use.
gdb/ChangeLog
2019-10-19 Tom Tromey <tom@tromey.com>
* NEWS: Add entry.
* maint.c (_initialize_maint_cmds): Add "worker-threads" maint
commands. Call update_thread_pool_size.
(update_thread_pool_size, maintenance_set_worker_threads): New
functions.
(n_worker_threads): New global.
gdb/doc/ChangeLog
2019-10-19 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document new maint
commands.
Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
---
M gdb/ChangeLog
M gdb/NEWS
M gdb/doc/ChangeLog
M gdb/doc/gdb.texinfo
M gdb/maint.c
5 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 400ccc1..d7b40d7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * NEWS: Add entry.
+ * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
+ commands. Call update_thread_pool_size.
+ (update_thread_pool_size, maintenance_set_worker_threads): New
+ functions.
+ (n_worker_threads): New global.
+
2019-10-19 Christian Biesinger <cbiesinger@google.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/NEWS b/gdb/NEWS
index 25e67e4..7c98c14 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -134,6 +134,13 @@
set style highlight intensity VALUE
Control the styling of highlightings.
+maint set worker-threads
+maint show worker-threads
+ Control the number of worker threads that can be used by GDB. The
+ default is "unlimited", which lets GDB choose a number that is
+ reasonable. Currently worker threads are only used when demangling
+ the names of linker symbols.
+
maint set test-settings KIND
maint show test-settings KIND
A set of commands used by the testsuite for exercising the settings
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 26f858f..175fc98 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * gdb.texinfo (Maintenance Commands): Document new maint
+ commands.
+
2019-10-07 Tom de Vries <tdevries@suse.de>
* gdb.texinfo: Fix typo.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 1208e4f..3219e68 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37683,6 +37683,21 @@
If DWARF frame unwinders are not supported for a particular target
architecture, then enabling this flag does not cause them to be used.
+
+@kindex maint set worker-threads
+@kindex maint show worker-threads
+@item maint set worker-threads
+@item maint show worker-threads
+Control the number of worker threads that may be used by @value{GDBN}.
+On capable hosts, @value{GDBN} may use multiple threads to speed up
+certain CPU-intensive operations, such as demangling symbol names.
+While the number of threads used by @value{GDBN} may vary, this
+command can be used to set an upper bound on this number. The default
+is @code{unlimited}, which lets @value{GDBN} choose a reasonable
+number. Note that this only controls worker threads started by
+@value{GDBN} itself; libraries used by @value{GDBN} may start threads
+of their own.
+
@kindex maint set profile
@kindex maint show profile
@cindex profiling GDB
diff --git a/gdb/maint.c b/gdb/maint.c
index ec9f4ab..fce1a1c 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -46,6 +46,10 @@
#include "cli/cli-setshow.h"
#include "cli/cli-cmds.h"
+#if CXX_STD_THREAD
+#include "gdbsupport/thread-pool.h"
+#endif
+
static void maintenance_do_deprecate (const char *, int);
/* Access the maintenance subcommands. */
@@ -840,6 +844,37 @@
error (_("Profiling support is not available on this system."));
}
#endif
+
+static int n_worker_threads = -1;
+
+/* Update the thread pool for the desired number of threads. */
+static void
+update_thread_pool_size ()
+{
+#if CXX_STD_THREAD
+ int n_threads = n_worker_threads;
+
+ if (n_threads < 0)
+ {
+ n_threads = std::thread::hardware_concurrency ();
+ if (n_threads == 0)
+ {
+ /* Meh. */
+ n_threads = 2;
+ }
+ }
+
+ gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
+#endif
+}
+
+static void
+maintenance_set_worker_threads (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_thread_pool_size ();
+}
+
\f
/* If true, display time usage both at startup and for each command. */
@@ -1312,4 +1347,17 @@
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_unlimited_cmd ("worker-threads",
+ class_maintenance,
+ &n_worker_threads, _("\
+Set the number of worker threads GDB can use."), _("\
+Set the number of worker threads GDB can use."), _("\
+GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
+such as demangling symbol names."),
+ maintenance_set_worker_threads, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+
+ update_thread_pool_size ();
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v3] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
2019-10-20 6:31 ` Eli Zaretskii
2019-10-20 20:55 ` [review v2] " Tom Tromey (Code Review)
@ 2019-10-30 23:00 ` Tom Tromey (Code Review)
2019-11-19 2:57 ` Christian Biesinger (Code Review)
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-30 23:00 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Add maint set/show worker-threads
This adds maint commands to control the number of worker threads that
gdb can use.
2019-10-19 Tom Tromey <tom@tromey.com>
* NEWS: Add entry.
* maint.c (_initialize_maint_cmds): Add "worker-threads" maint
commands. Call update_thread_pool_size.
(update_thread_pool_size, maintenance_set_worker_threads): New
functions.
(n_worker_threads): New global.
gdb/doc/ChangeLog
2019-10-19 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document new maint
commands.
Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
---
M gdb/ChangeLog
M gdb/NEWS
M gdb/doc/ChangeLog
M gdb/doc/gdb.texinfo
M gdb/maint.c
5 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 065c752..a103cf5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * NEWS: Add entry.
+ * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
+ commands. Call update_thread_pool_size.
+ (update_thread_pool_size, maintenance_set_worker_threads): New
+ functions.
+ (n_worker_threads): New global.
+
2019-10-19 Christian Biesinger <cbiesinger@google.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/NEWS b/gdb/NEWS
index 7613598..6ccf376 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -140,6 +140,13 @@
set style highlight intensity VALUE
Control the styling of highlightings.
+maint set worker-threads
+maint show worker-threads
+ Control the number of worker threads that can be used by GDB. The
+ default is "unlimited", which lets GDB choose a number that is
+ reasonable. Currently worker threads are only used when demangling
+ the names of linker symbols.
+
maint set test-settings KIND
maint show test-settings KIND
A set of commands used by the testsuite for exercising the settings
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index c1538be..82a12f2 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * gdb.texinfo (Maintenance Commands): Document new maint
+ commands.
+
2019-10-29 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Also set SYSTEM_GDBINIT_DIR for the info manual
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index db3d15b..3a12fac 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37723,6 +37723,21 @@
If DWARF frame unwinders are not supported for a particular target
architecture, then enabling this flag does not cause them to be used.
+
+@kindex maint set worker-threads
+@kindex maint show worker-threads
+@item maint set worker-threads
+@item maint show worker-threads
+Control the number of worker threads that may be used by @value{GDBN}.
+On capable hosts, @value{GDBN} may use multiple threads to speed up
+certain CPU-intensive operations, such as demangling symbol names.
+While the number of threads used by @value{GDBN} may vary, this
+command can be used to set an upper bound on this number. The default
+is @code{unlimited}, which lets @value{GDBN} choose a reasonable
+number. Note that this only controls worker threads started by
+@value{GDBN} itself; libraries used by @value{GDBN} may start threads
+of their own.
+
@kindex maint set profile
@kindex maint show profile
@cindex profiling GDB
diff --git a/gdb/maint.c b/gdb/maint.c
index ec9f4ab..fce1a1c 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -46,6 +46,10 @@
#include "cli/cli-setshow.h"
#include "cli/cli-cmds.h"
+#if CXX_STD_THREAD
+#include "gdbsupport/thread-pool.h"
+#endif
+
static void maintenance_do_deprecate (const char *, int);
/* Access the maintenance subcommands. */
@@ -840,6 +844,37 @@
error (_("Profiling support is not available on this system."));
}
#endif
+
+static int n_worker_threads = -1;
+
+/* Update the thread pool for the desired number of threads. */
+static void
+update_thread_pool_size ()
+{
+#if CXX_STD_THREAD
+ int n_threads = n_worker_threads;
+
+ if (n_threads < 0)
+ {
+ n_threads = std::thread::hardware_concurrency ();
+ if (n_threads == 0)
+ {
+ /* Meh. */
+ n_threads = 2;
+ }
+ }
+
+ gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
+#endif
+}
+
+static void
+maintenance_set_worker_threads (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_thread_pool_size ();
+}
+
\f
/* If true, display time usage both at startup and for each command. */
@@ -1312,4 +1347,17 @@
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_unlimited_cmd ("worker-threads",
+ class_maintenance,
+ &n_worker_threads, _("\
+Set the number of worker threads GDB can use."), _("\
+Set the number of worker threads GDB can use."), _("\
+GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
+such as demangling symbol names."),
+ maintenance_set_worker_threads, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+
+ update_thread_pool_size ();
}
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Gerrit-Change-Number: 174
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v3] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
` (2 preceding siblings ...)
2019-10-30 23:00 ` [review v3] " Tom Tromey (Code Review)
@ 2019-11-19 2:57 ` Christian Biesinger (Code Review)
2019-11-22 23:50 ` [review v4] " Tom Tromey (Code Review)
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-11-19 2:57 UTC (permalink / raw)
To: Tom Tromey, gdb-patches; +Cc: Christian Biesinger
Christian Biesinger has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Patch Set 3:
(1 comment)
| --- gdb/maint.c
| +++ gdb/maint.c
| @@ -1311,5 +1346,18 @@ When enabled GDB is profiled."),
| maintenance_set_profile_cmd,
| show_maintenance_profile_p,
| &maintenance_set_cmdlist,
| &maintenance_show_cmdlist);
| +
| + add_setshow_zuinteger_unlimited_cmd ("worker-threads",
| + class_maintenance,
| + &n_worker_threads, _("\
| +Set the number of worker threads GDB can use."), _("\
| +Set the number of worker threads GDB can use."), _("\
PS3, Line 1355:
Should this be "Show"? I think this is the cause for the missing T
here:
(gdb) maint show worker-threads
He number of worker threads GDB can use is unlimited.
| +GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
| +such as demangling symbol names."),
| + maintenance_set_worker_threads, NULL,
| + &maintenance_set_cmdlist,
| + &maintenance_show_cmdlist);
| +
| + update_thread_pool_size ();
| }
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Gerrit-Change-Number: 174
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-Comment-Date: Tue, 19 Nov 2019 02:57:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v4] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
` (3 preceding siblings ...)
2019-11-19 2:57 ` Christian Biesinger (Code Review)
@ 2019-11-22 23:50 ` Tom Tromey (Code Review)
2019-11-23 7:20 ` Eli Zaretskii
2019-11-26 19:18 ` Pedro Alves (Code Review)
` (3 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-22 23:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Add maint set/show worker-threads
This adds maint commands to control the number of worker threads that
gdb can use.
2019-10-19 Tom Tromey <tom@tromey.com>
* NEWS: Add entry.
* maint.c (_initialize_maint_cmds): Add "worker-threads" maint
commands. Call update_thread_pool_size.
(update_thread_pool_size, maintenance_set_worker_threads): New
functions.
(n_worker_threads): New global.
gdb/doc/ChangeLog
2019-10-19 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document new maint
commands.
Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
---
M gdb/ChangeLog
M gdb/NEWS
M gdb/doc/ChangeLog
M gdb/doc/gdb.texinfo
M gdb/maint.c
5 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7640945..1d627af 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * NEWS: Add entry.
+ * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
+ commands. Call update_thread_pool_size.
+ (update_thread_pool_size, maintenance_set_worker_threads): New
+ functions.
+ (n_worker_threads): New global.
+
2019-10-19 Christian Biesinger <cbiesinger@google.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/NEWS b/gdb/NEWS
index b0f5447..cb5927a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -149,6 +149,13 @@
set style highlight intensity VALUE
Control the styling of highlightings.
+maint set worker-threads
+maint show worker-threads
+ Control the number of worker threads that can be used by GDB. The
+ default is "unlimited", which lets GDB choose a number that is
+ reasonable. Currently worker threads are only used when demangling
+ the names of linker symbols.
+
maint set test-settings KIND
maint show test-settings KIND
A set of commands used by the testsuite for exercising the settings
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 2571839..340fee6 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-19 Tom Tromey <tom@tromey.com>
+
+ * gdb.texinfo (Maintenance Commands): Document new maint
+ commands.
+
2019-11-14 Tom de Vries <tdevries@suse.de>
* gdb.texinfo: Fix typos.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index c66a39c..cfb0acb 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37863,6 +37863,21 @@
If DWARF frame unwinders are not supported for a particular target
architecture, then enabling this flag does not cause them to be used.
+
+@kindex maint set worker-threads
+@kindex maint show worker-threads
+@item maint set worker-threads
+@item maint show worker-threads
+Control the number of worker threads that may be used by @value{GDBN}.
+On capable hosts, @value{GDBN} may use multiple threads to speed up
+certain CPU-intensive operations, such as demangling symbol names.
+While the number of threads used by @value{GDBN} may vary, this
+command can be used to set an upper bound on this number. The default
+is @code{unlimited}, which lets @value{GDBN} choose a reasonable
+number. Note that this only controls worker threads started by
+@value{GDBN} itself; libraries used by @value{GDBN} may start threads
+of their own.
+
@kindex maint set profile
@kindex maint show profile
@cindex profiling GDB
diff --git a/gdb/maint.c b/gdb/maint.c
index ce59ef6..b191857 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -46,6 +46,10 @@
#include "cli/cli-setshow.h"
#include "cli/cli-cmds.h"
+#if CXX_STD_THREAD
+#include "gdbsupport/thread-pool.h"
+#endif
+
static void maintenance_do_deprecate (const char *, int);
/* Access the maintenance subcommands. */
@@ -840,6 +844,37 @@
error (_("Profiling support is not available on this system."));
}
#endif
+
+static int n_worker_threads = -1;
+
+/* Update the thread pool for the desired number of threads. */
+static void
+update_thread_pool_size ()
+{
+#if CXX_STD_THREAD
+ int n_threads = n_worker_threads;
+
+ if (n_threads < 0)
+ {
+ n_threads = std::thread::hardware_concurrency ();
+ if (n_threads == 0)
+ {
+ /* Meh. */
+ n_threads = 2;
+ }
+ }
+
+ gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
+#endif
+}
+
+static void
+maintenance_set_worker_threads (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_thread_pool_size ();
+}
+
\f
/* If true, display time usage both at startup and for each command. */
@@ -1313,4 +1348,17 @@
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_unlimited_cmd ("worker-threads",
+ class_maintenance,
+ &n_worker_threads, _("\
+Set the number of worker threads GDB can use."), _("\
+Show the number of worker threads GDB can use."), _("\
+GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
+such as demangling symbol names."),
+ maintenance_set_worker_threads, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+
+ update_thread_pool_size ();
}
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Gerrit-Change-Number: 174
Gerrit-PatchSet: 4
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [review v4] Add maint set/show worker-threads
2019-11-22 23:50 ` [review v4] " Tom Tromey (Code Review)
@ 2019-11-23 7:20 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2019-11-23 7:20 UTC (permalink / raw)
To: tromey, cbiesinger, gdb-patches
> Date: Fri, 22 Nov 2019 18:50:07 -0500
> From: "Tom Tromey (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
> ......................................................................
>
> Add maint set/show worker-threads
>
> This adds maint commands to control the number of worker threads that
> gdb can use.
>
> 2019-10-19 Tom Tromey <tom@tromey.com>
>
> * NEWS: Add entry.
> * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
> commands. Call update_thread_pool_size.
> (update_thread_pool_size, maintenance_set_worker_threads): New
> functions.
> (n_worker_threads): New global.
>
> gdb/doc/ChangeLog
> 2019-10-19 Tom Tromey <tom@tromey.com>
>
> * gdb.texinfo (Maintenance Commands): Document new maint
> commands.
OK for the documentation parts.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v4] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
` (4 preceding siblings ...)
2019-11-22 23:50 ` [review v4] " Tom Tromey (Code Review)
@ 2019-11-26 19:18 ` Pedro Alves (Code Review)
2019-11-26 19:50 ` Tom Tromey (Code Review)
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-26 19:18 UTC (permalink / raw)
To: Tom Tromey, gdb-patches; +Cc: Christian Biesinger
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Patch Set 4: Code-Review+2
(1 comment)
Minor comment below, but otherwise LGTM.
| --- gdb/maint.c
| +++ gdb/maint.c
| @@ -843,0 +854,19 @@ update_thread_pool_size ()
| +#if CXX_STD_THREAD
| + int n_threads = n_worker_threads;
| +
| + if (n_threads < 0)
| + {
| + n_threads = std::thread::hardware_concurrency ();
| + if (n_threads == 0)
| + {
| + /* Meh. */
| + n_threads = 2;
PS4, Line 863:
If we have no concurrency, then shouldn't we fallback to no extra
threads? Presumably the threads in the poll will be running CPU-bound
code, so more threads in the same hardware core/thread won't help,
right?
BTW, JIC, did you check if setting the number of threads to 0 behaves
OK?
| + }
| + }
| +
| + gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
| +#endif
| +}
| +
| +static void
| +maintenance_set_worker_threads (const char *args, int from_tty,
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Gerrit-Change-Number: 174
Gerrit-PatchSet: 4
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-Comment-Date: Tue, 26 Nov 2019 19:18:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v4] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
` (5 preceding siblings ...)
2019-11-26 19:18 ` Pedro Alves (Code Review)
@ 2019-11-26 19:50 ` Tom Tromey (Code Review)
2019-11-26 21:14 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
8 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-26 19:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Pedro Alves, Christian Biesinger
Tom Tromey has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Patch Set 4:
(1 comment)
| --- gdb/maint.c
| +++ gdb/maint.c
| @@ -843,0 +854,19 @@ update_thread_pool_size ()
| +#if CXX_STD_THREAD
| + int n_threads = n_worker_threads;
| +
| + if (n_threads < 0)
| + {
| + n_threads = std::thread::hardware_concurrency ();
| + if (n_threads == 0)
| + {
| + /* Meh. */
| + n_threads = 2;
PS4, Line 863:
> If we have no concurrency, then shouldn't we fallback to no extra threads? Presumably the threads in the poll will be running CPU-bound code, so more threads in the same hardware core/thread won't help, right?
I changed this to let it just be 0.
> BTW, JIC, did you check if setting the number of threads to 0 behaves OK?
Yep.
| + }
| + }
| +
| + gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
| +#endif
| +}
| +
| +static void
| +maintenance_set_worker_threads (const char *args, int from_tty,
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Gerrit-Change-Number: 174
Gerrit-PatchSet: 4
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-Comment-Date: Tue, 26 Nov 2019 19:50:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Pedro Alves <palves@redhat.com>
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pushed] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
` (6 preceding siblings ...)
2019-11-26 19:50 ` Tom Tromey (Code Review)
@ 2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
8 siblings, 0 replies; 11+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-26 21:14 UTC (permalink / raw)
To: Tom Tromey, Pedro Alves, gdb-patches; +Cc: Christian Biesinger
The original change was created by Tom Tromey.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Add maint set/show worker-threads
This adds maint commands to control the number of worker threads that
gdb can use.
2019-11-26 Tom Tromey <tom@tromey.com>
* NEWS: Add entry.
* maint.c (_initialize_maint_cmds): Add "worker-threads" maint
commands. Call update_thread_pool_size.
(update_thread_pool_size, maintenance_set_worker_threads): New
functions.
(n_worker_threads): New global.
gdb/doc/ChangeLog
2019-11-26 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document new maint
commands.
Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
---
M gdb/ChangeLog
M gdb/NEWS
M gdb/doc/ChangeLog
M gdb/doc/gdb.texinfo
M gdb/maint.c
5 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b73ae8d..289cbce 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2019-11-26 Tom Tromey <tom@tromey.com>
+
+ * NEWS: Add entry.
+ * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
+ commands. Call update_thread_pool_size.
+ (update_thread_pool_size, maintenance_set_worker_threads): New
+ functions.
+ (n_worker_threads): New global.
+
2019-11-26 Christian Biesinger <cbiesinger@google.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/NEWS b/gdb/NEWS
index 01b38cf..5fd0f41 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -149,6 +149,13 @@
set style highlight intensity VALUE
Control the styling of highlightings.
+maint set worker-threads
+maint show worker-threads
+ Control the number of worker threads that can be used by GDB. The
+ default is "unlimited", which lets GDB choose a number that is
+ reasonable. Currently worker threads are only used when demangling
+ the names of linker symbols.
+
maint set test-settings KIND
maint show test-settings KIND
A set of commands used by the testsuite for exercising the settings
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index c6fa5f5..06d7a6d 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-26 Tom Tromey <tom@tromey.com>
+
+ * gdb.texinfo (Maintenance Commands): Document new maint
+ commands.
+
2019-11-25 Luis Machado <luis.machado@linaro.org>
* gdb.texinfo (Debugging Output): Document set debug
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 18bb18b..e3be0cd 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37876,6 +37876,21 @@
If DWARF frame unwinders are not supported for a particular target
architecture, then enabling this flag does not cause them to be used.
+
+@kindex maint set worker-threads
+@kindex maint show worker-threads
+@item maint set worker-threads
+@item maint show worker-threads
+Control the number of worker threads that may be used by @value{GDBN}.
+On capable hosts, @value{GDBN} may use multiple threads to speed up
+certain CPU-intensive operations, such as demangling symbol names.
+While the number of threads used by @value{GDBN} may vary, this
+command can be used to set an upper bound on this number. The default
+is @code{unlimited}, which lets @value{GDBN} choose a reasonable
+number. Note that this only controls worker threads started by
+@value{GDBN} itself; libraries used by @value{GDBN} may start threads
+of their own.
+
@kindex maint set profile
@kindex maint show profile
@cindex profiling GDB
diff --git a/gdb/maint.c b/gdb/maint.c
index ce59ef6..7ab3fdb 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -46,6 +46,10 @@
#include "cli/cli-setshow.h"
#include "cli/cli-cmds.h"
+#if CXX_STD_THREAD
+#include "gdbsupport/thread-pool.h"
+#endif
+
static void maintenance_do_deprecate (const char *, int);
/* Access the maintenance subcommands. */
@@ -840,6 +844,30 @@
error (_("Profiling support is not available on this system."));
}
#endif
+
+static int n_worker_threads = -1;
+
+/* Update the thread pool for the desired number of threads. */
+static void
+update_thread_pool_size ()
+{
+#if CXX_STD_THREAD
+ int n_threads = n_worker_threads;
+
+ if (n_threads < 0)
+ n_threads = std::thread::hardware_concurrency ();
+
+ gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
+#endif
+}
+
+static void
+maintenance_set_worker_threads (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_thread_pool_size ();
+}
+
\f
/* If true, display time usage both at startup and for each command. */
@@ -1313,4 +1341,17 @@
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_unlimited_cmd ("worker-threads",
+ class_maintenance,
+ &n_worker_threads, _("\
+Set the number of worker threads GDB can use."), _("\
+Show the number of worker threads GDB can use."), _("\
+GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
+such as demangling symbol names."),
+ maintenance_set_worker_threads, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+
+ update_thread_pool_size ();
}
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Gerrit-Change-Number: 174
Gerrit-PatchSet: 5
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pushed] Add maint set/show worker-threads
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
` (7 preceding siblings ...)
2019-11-26 21:14 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
8 siblings, 0 replies; 11+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-26 21:14 UTC (permalink / raw)
To: Tom Tromey, gdb-patches; +Cc: Pedro Alves, Christian Biesinger
Sourceware to Gerrit sync has submitted this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/174
......................................................................
Add maint set/show worker-threads
This adds maint commands to control the number of worker threads that
gdb can use.
2019-11-26 Tom Tromey <tom@tromey.com>
* NEWS: Add entry.
* maint.c (_initialize_maint_cmds): Add "worker-threads" maint
commands. Call update_thread_pool_size.
(update_thread_pool_size, maintenance_set_worker_threads): New
functions.
(n_worker_threads): New global.
gdb/doc/ChangeLog
2019-11-26 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document new maint
commands.
Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
---
M gdb/ChangeLog
M gdb/NEWS
M gdb/doc/ChangeLog
M gdb/doc/gdb.texinfo
M gdb/maint.c
5 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b73ae8d..289cbce 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2019-11-26 Tom Tromey <tom@tromey.com>
+
+ * NEWS: Add entry.
+ * maint.c (_initialize_maint_cmds): Add "worker-threads" maint
+ commands. Call update_thread_pool_size.
+ (update_thread_pool_size, maintenance_set_worker_threads): New
+ functions.
+ (n_worker_threads): New global.
+
2019-11-26 Christian Biesinger <cbiesinger@google.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/NEWS b/gdb/NEWS
index 01b38cf..5fd0f41 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -149,6 +149,13 @@
set style highlight intensity VALUE
Control the styling of highlightings.
+maint set worker-threads
+maint show worker-threads
+ Control the number of worker threads that can be used by GDB. The
+ default is "unlimited", which lets GDB choose a number that is
+ reasonable. Currently worker threads are only used when demangling
+ the names of linker symbols.
+
maint set test-settings KIND
maint show test-settings KIND
A set of commands used by the testsuite for exercising the settings
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index c6fa5f5..06d7a6d 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-26 Tom Tromey <tom@tromey.com>
+
+ * gdb.texinfo (Maintenance Commands): Document new maint
+ commands.
+
2019-11-25 Luis Machado <luis.machado@linaro.org>
* gdb.texinfo (Debugging Output): Document set debug
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 18bb18b..e3be0cd 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37876,6 +37876,21 @@
If DWARF frame unwinders are not supported for a particular target
architecture, then enabling this flag does not cause them to be used.
+
+@kindex maint set worker-threads
+@kindex maint show worker-threads
+@item maint set worker-threads
+@item maint show worker-threads
+Control the number of worker threads that may be used by @value{GDBN}.
+On capable hosts, @value{GDBN} may use multiple threads to speed up
+certain CPU-intensive operations, such as demangling symbol names.
+While the number of threads used by @value{GDBN} may vary, this
+command can be used to set an upper bound on this number. The default
+is @code{unlimited}, which lets @value{GDBN} choose a reasonable
+number. Note that this only controls worker threads started by
+@value{GDBN} itself; libraries used by @value{GDBN} may start threads
+of their own.
+
@kindex maint set profile
@kindex maint show profile
@cindex profiling GDB
diff --git a/gdb/maint.c b/gdb/maint.c
index ce59ef6..7ab3fdb 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -46,6 +46,10 @@
#include "cli/cli-setshow.h"
#include "cli/cli-cmds.h"
+#if CXX_STD_THREAD
+#include "gdbsupport/thread-pool.h"
+#endif
+
static void maintenance_do_deprecate (const char *, int);
/* Access the maintenance subcommands. */
@@ -840,6 +844,30 @@
error (_("Profiling support is not available on this system."));
}
#endif
+
+static int n_worker_threads = -1;
+
+/* Update the thread pool for the desired number of threads. */
+static void
+update_thread_pool_size ()
+{
+#if CXX_STD_THREAD
+ int n_threads = n_worker_threads;
+
+ if (n_threads < 0)
+ n_threads = std::thread::hardware_concurrency ();
+
+ gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
+#endif
+}
+
+static void
+maintenance_set_worker_threads (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_thread_pool_size ();
+}
+
\f
/* If true, display time usage both at startup and for each command. */
@@ -1313,4 +1341,17 @@
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_unlimited_cmd ("worker-threads",
+ class_maintenance,
+ &n_worker_threads, _("\
+Set the number of worker threads GDB can use."), _("\
+Show the number of worker threads GDB can use."), _("\
+GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
+such as demangling symbol names."),
+ maintenance_set_worker_threads, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+
+ update_thread_pool_size ();
}
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Gerrit-Change-Number: 174
Gerrit-PatchSet: 5
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Christian Biesinger <cbiesinger@google.com>
Gerrit-MessageType: merged
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-11-26 21:14 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-20 3:55 [review] Add maint set/show worker-threads Tom Tromey (Code Review)
2019-10-20 6:31 ` Eli Zaretskii
2019-10-20 20:55 ` [review v2] " Tom Tromey (Code Review)
2019-10-30 23:00 ` [review v3] " Tom Tromey (Code Review)
2019-11-19 2:57 ` Christian Biesinger (Code Review)
2019-11-22 23:50 ` [review v4] " Tom Tromey (Code Review)
2019-11-23 7:20 ` Eli Zaretskii
2019-11-26 19:18 ` Pedro Alves (Code Review)
2019-11-26 19:50 ` Tom Tromey (Code Review)
2019-11-26 21:14 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
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).