From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 00/11] Various thread lists optimizations
Date: Mon, 12 Jul 2021 20:47:38 -0400 [thread overview]
Message-ID: <4027da72-9122-0c31-3673-fa359147f074@polymtl.ca> (raw)
In-Reply-To: <20210622165704.2404007-1-simon.marchi@polymtl.ca>
On 2021-06-22 12:56 p.m., Simon Marchi wrote:
> This series contains various optimizations written after profiling
> ROCm-GDB [1]. A typical ROCm program may have thousands of threads
> (waves), so everything that iterates often on the whole thread list pops
> up on the profile report.
>
> Conceptually, the optimizations are:
>
> - maintain a ptid -> thread map in each inferior, to speed up the
> thread lookups per ptid with find_thread_ptid
> - make all_matching_threads_iterator a bit smarter, depending on the
> filter_ptid passed, it can avoid iterating on all threads. When the
> filter_ptid points to a specific thread, it can use find_thread_ptid
> to directly find the thread of interest, which is fast thanks to the
> previous point
> - maintain a per-process-target list of threads that are resumed and
> have a pending event. This helps speed up two hot path cases: when
> we check if we want to re-enable commit-resumed, and when we want to
> fetch a pending event.
>
> Patches up to and including patch 6 are groundwork. Notably, patch 2
> (thanks to Pedro) adds an intrusive_list type, which allows using
> intrusive linked lists in a very C++-y way without writing a ton of
> boilerplate. This list type is useful for the patch that maintains a
> list of resumed threads with pending events, but we also converted the
> per-inferior thread list, the inferior list and the thread
> step-over-list to use it. It helped iron out a few bugs and ensure the
> list works well for our purposes.
>
> When debugging a ROCm test program whose threads continuously hit a
> condition breakpoint evaluation to false, the speedup observed with
> ROCm-GDB is around 5x (a run takes about 30 seconds before and 6 seconds
> after).
>
> With x86-64 / Linux, it's less noticeable, because the time we spend in
> syscalls to fetch events and resume threads still dominates. Still,
> when trying a program with 1000 threads hitting 100 times each a false
> conditional breakpoint, it goes from ~20 seconds to ~16 seconds. But I
> don't really expect anything that noticeable in everyday use cases
> though.
>
> [1] https://github.com/ROCm-Developer-Tools/ROCgdb
>
> Pedro Alves (2):
> gdb: introduce intrusive_list, make thread_info use it
> gdb: make inferior_list use intrusive_list
>
> Simon Marchi (9):
> gdb: introduce iterator_range, remove next_adapter
> gdb: use intrusive list for step-over chain
> gdb: add setter / getter for thread_info resumed state
> gdb: make thread_info::suspend private, add getters / setters
> gdb: maintain per-process-target list of resumed threads with pending
> wait status
> gdb: optimize check for resumed threads with pending wait status in
> maybe_set_commit_resumed_all_targets
> gdb: optimize selection of resumed thread with pending event
> gdb: maintain ptid -> thread map, optimize find_thread_ptid
> gdb: optimize all_matching_threads_iterator
>
> gdb/Makefile.in | 1 +
> gdb/ada-tasks.c | 4 +-
> gdb/breakpoint.c | 7 +-
> gdb/breakpoint.h | 10 +-
> gdb/elf-none-tdep.c | 2 +-
> gdb/fbsd-tdep.c | 6 +-
> gdb/gcore.c | 4 +-
> gdb/gdb-gdb.py.in | 91 ++-
> gdb/gdb_bfd.h | 4 +-
> gdb/gdbthread.h | 192 ++++-
> gdb/infcmd.c | 33 +-
> gdb/inferior-iter.h | 94 +--
> gdb/inferior.c | 105 ++-
> gdb/inferior.h | 34 +-
> gdb/inflow.c | 2 +-
> gdb/infrun.c | 476 ++++++------
> gdb/infrun.h | 4 +-
> gdb/linux-fork.c | 3 +-
> gdb/linux-nat.c | 12 +-
> gdb/linux-tdep.c | 2 +-
> gdb/objfiles.h | 6 +-
> gdb/process-stratum-target.c | 77 ++
> gdb/process-stratum-target.h | 26 +
> gdb/progspace.c | 11 +-
> gdb/progspace.h | 45 +-
> gdb/psymtab.h | 2 +-
> gdb/python/py-inferior.c | 2 +-
> gdb/record-btrace.c | 3 +-
> gdb/record-full.c | 3 +-
> gdb/regcache.c | 6 +-
> gdb/remote.c | 68 +-
> gdb/scoped-mock-context.h | 15 +-
> gdb/solist.h | 2 +
> gdb/symtab.h | 15 +-
> gdb/thread-iter.c | 147 +++-
> gdb/thread-iter.h | 61 +-
> gdb/thread.c | 216 +++---
> gdb/top.h | 6 +-
> gdb/unittests/intrusive_list-selftests.c | 818 +++++++++++++++++++++
> gdbsupport/intrusive_list.h | 586 +++++++++++++++
> gdbsupport/iterator-range.h | 60 ++
> gdbsupport/next-iterator.h | 32 +-
> gdbsupport/reference-to-pointer-iterator.h | 82 +++
> 43 files changed, 2574 insertions(+), 801 deletions(-)
> create mode 100644 gdb/unittests/intrusive_list-selftests.c
> create mode 100644 gdbsupport/intrusive_list.h
> create mode 100644 gdbsupport/iterator-range.h
> create mode 100644 gdbsupport/reference-to-pointer-iterator.h
>
I pushed this series after addressing Pedro's comments.
Simon
prev parent reply other threads:[~2021-07-13 0:48 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 16:56 Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 01/11] gdb: introduce iterator_range, remove next_adapter Simon Marchi via Gdb-patches
2021-07-05 15:41 ` Pedro Alves
2021-07-06 19:16 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 02/11] gdb: introduce intrusive_list, make thread_info use it Simon Marchi via Gdb-patches
2021-06-22 23:13 ` Lancelot SIX via Gdb-patches
2021-06-23 0:48 ` Simon Marchi via Gdb-patches
2021-07-05 15:44 ` Pedro Alves
2021-07-06 19:38 ` Simon Marchi via Gdb-patches
2021-07-06 20:45 ` Simon Marchi via Gdb-patches
2021-07-06 21:04 ` Pedro Alves
2021-07-06 21:38 ` Simon Marchi via Gdb-patches
2021-07-06 21:02 ` Pedro Alves
2021-07-06 21:45 ` Simon Marchi via Gdb-patches
2021-07-07 11:46 ` Pedro Alves
2021-07-07 13:52 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 03/11] gdb: make inferior_list use intrusive_list Simon Marchi via Gdb-patches
2021-07-05 15:44 ` Pedro Alves
2021-07-14 6:34 ` Tom de Vries
2021-07-14 16:11 ` Simon Marchi via Gdb-patches
2021-07-14 20:15 ` [PATCH] gdb: make all_inferiors_safe actually work Simon Marchi via Gdb-patches
2021-07-15 10:15 ` Tom de Vries
2021-07-17 12:54 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 04/11] gdb: use intrusive list for step-over chain Simon Marchi via Gdb-patches
2021-07-05 15:45 ` Pedro Alves
2021-07-06 20:59 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 05/11] gdb: add setter / getter for thread_info resumed state Simon Marchi via Gdb-patches
2021-07-05 15:45 ` Pedro Alves
2021-06-22 16:56 ` [PATCH 06/11] gdb: make thread_info::suspend private, add getters / setters Simon Marchi via Gdb-patches
2021-07-05 15:45 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 07/11] gdb: maintain per-process-target list of resumed threads with pending wait status Simon Marchi via Gdb-patches
2021-07-05 15:51 ` Pedro Alves
2021-07-06 21:25 ` Simon Marchi via Gdb-patches
2021-07-07 12:01 ` Pedro Alves
2021-07-12 22:28 ` Simon Marchi via Gdb-patches
2021-07-12 22:34 ` Simon Marchi via Gdb-patches
2021-07-13 12:21 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 08/11] gdb: optimize check for resumed threads with pending wait status in maybe_set_commit_resumed_all_targets Simon Marchi via Gdb-patches
2021-07-05 15:51 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 09/11] gdb: optimize selection of resumed thread with pending event Simon Marchi via Gdb-patches
2021-07-05 15:51 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 10/11] gdb: maintain ptid -> thread map, optimize find_thread_ptid Simon Marchi via Gdb-patches
2021-07-05 15:52 ` Pedro Alves
2021-07-06 21:31 ` Simon Marchi via Gdb-patches
2021-07-07 12:13 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 11/11] gdb: optimize all_matching_threads_iterator Simon Marchi via Gdb-patches
2021-07-05 15:52 ` Pedro Alves
2021-07-14 9:40 ` Tom de Vries
2021-07-13 0:47 ` Simon Marchi via Gdb-patches [this message]
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=4027da72-9122-0c31-3673-fa359147f074@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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