binutils-gdb/gdb/python
Lancelot SIX 40b355f24e gdb/py-inferior: Keep inferior threads in a map
The python code maintains a list of threads for each inferior.  This
list is implemented as a linked list.  When the number of threads grows
high, this implementation can begin to be a performance bottleneck as
finding a particular thread_object in the list has a complexity of O(N).

We see this in ROCgdb[1], a downstream port of GDB for AMDGUP.  On
AMDGPU devices, the number of threads can get significantly higher than
on usual GDB workloads.

In some situations, we can reach the end of the inferior process with
GDB still having a substantial list of known threads.  While running
target_mourn_inferior, we end up in inferior::clear_thread_list which
iterates over all remaining threads and marks each thread exited.  This
fires the gdb::observers::thread_exit observer and eventually
py-inferior.c:set_thread_exited gets called.  This function searches in
the linked list with poor performances.

This patch proposes to change the linked list that keeps the per
inferior_object list of thread_objects into a std::unordered_map.  This
allows to have the search operation complexity be O(1) on average
instead of O(N).

With this patch, we can complete clear_thread_list in about 2.5 seconds
compared to 10 minutes without it.

Except for the performance change, no user visible change is expected.

Regression tested on Ubuntu-22.04 x86_64.

[1] https://github.com/ROCm-Developer-Tools/ROCgdb
2022-11-11 13:50:19 +00:00
..
lib/gdb GDB/Python: Make None' stand for unlimited' in setting integer parameters 2022-10-21 08:54:18 +01:00
py-all-events.def Add gdb.free_objfile event registry 2022-07-18 11:25:34 -06:00
py-arch.c Use registry in gdbarch 2022-08-04 13:28:04 -06:00
py-auto-load.c
py-block.c Rewrite registry.h 2022-07-28 14:16:50 -06:00
py-bpevent.c
py-breakpoint.c gdb/python: break more dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-cmd.c Use PyBool_FromLong 2022-06-23 09:27:30 -06:00
py-connection.c
py-continueevent.c
py-disasm.c gdb/python: fix invalid use disassemble_info::stream 2022-07-25 19:26:24 +01:00
py-event-types.def Add gdb.free_objfile event registry 2022-07-18 11:25:34 -06:00
py-event.c
py-event.h Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-events.h Use bool for evregpy_no_listeners_p 2022-06-03 10:35:30 -06:00
py-evtregistry.c Make 'import gdb.events' work 2022-07-05 10:28:39 -06:00
py-evts.c Make 'import gdb.events' work 2022-07-05 10:28:39 -06:00
py-exitedevent.c
py-finishbreakpoint.c gdb/python: break more dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-frame.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-framefilter.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-function.c
py-gdb-readline.c
py-inferior.c gdb/py-inferior: Keep inferior threads in a map 2022-11-11 13:50:19 +00:00
py-infevents.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-infthread.c
py-instruction.c gdb/python: break dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-instruction.h gdb/python: break dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-lazy-string.c gdb: remove TYPE_TARGET_TYPE 2022-09-21 10:59:49 -04:00
py-linetable.c
py-membuf.c
py-micmd.c
py-newobjfileevent.c Add gdb.free_objfile event registry 2022-07-18 11:25:34 -06:00
py-objfile.c gdb, python: use gdbarch_iterate_over_objfiles_in_search_order 2022-10-18 14:16:09 +02:00
py-param.c GDB/Python: Make None' stand for unlimited' in setting integer parameters 2022-10-21 08:54:18 +01:00
py-prettyprint.c gdb: remove TYPE_LENGTH 2022-09-21 11:05:21 -04:00
py-progspace.c Rewrite registry.h 2022-07-28 14:16:50 -06:00
py-record-btrace.c
py-record-btrace.h
py-record-full.c
py-record-full.h
py-record.c gdb/python: break dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-record.h
py-ref.h
py-registers.c Fix crash in gdbpy_parse_register_id 2022-08-21 08:03:42 -06:00
py-signalevent.c
py-stopevent.c
py-stopevent.h
py-symbol.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-symtab.c Rewrite registry.h 2022-07-28 14:16:50 -06:00
py-threadevent.c
py-tui.c
py-type.c Add missing TYPE_CODE_* constants to Python 2022-10-31 12:47:36 -06:00
py-unwind.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-utils.c gdb/python: convert gdbpy_err_fetch to use gdbpy_ref 2022-06-15 09:44:54 +01:00
py-value.c gdb: remove TYPE_LENGTH 2022-09-21 11:05:21 -04:00
py-varobj.c Expose current 'print' settings to Python 2022-07-15 09:25:33 -06:00
py-xmethods.c
python-config.py gdb/python-config: replace deprecated distutils.sysconfig 2022-09-01 04:51:33 -04:00
python-internal.h gdb/python: break more dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
python.c gdb, python: use gdbarch_iterate_over_objfiles_in_search_order 2022-10-18 14:16:09 +02:00
python.h gdb, python: use gdbarch_iterate_over_objfiles_in_search_order 2022-10-18 14:16:09 +02:00