Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Pedro Alves <pedro@palves.net>,
	Simon Marchi <simon.marchi@polymtl.ca>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH 11/11] gdb: optimize all_matching_threads_iterator
Date: Wed, 14 Jul 2021 11:40:38 +0200	[thread overview]
Message-ID: <7a178941-a14c-27a5-4d39-4246a5d786f9@suse.de> (raw)
In-Reply-To: <db5b9f0d-49c4-d298-2f11-6cd8a237e602@palves.net>

On 7/5/21 5:52 PM, Pedro Alves wrote:
> On 2021-06-22 5:57 p.m., Simon Marchi via Gdb-patches wrote:
>> all_matching_threads_iterator is used extensively in some pretty fast
>> paths, often under the all_non_exited_threads function.
>>
>> If a filter target and thread-specific ptid are given, it iterates on
>> all threads of all inferiors of that target, to ultimately yield exactly
>> on thread.  And this happens quite often, which means we unnecessarily
>> spend time iterating on threads to find the one we are looking for.  The
>> same thing happens if an inferior-specific ptid is given, although there
>> the iterator yields all the threads of that inferior.
>>
>> In those cases, the callers of all_non_exited_threads could have
>> different behaviors depending on the kind of ptid, to avoid this
>> inefficiency, but that would be very tedious.  Using
>> all_non_exited_threads has the advantage that one simple implementation
>> can work seamlessly on multiple threads or on one specific thread, just
>> by playing with the ptid.
>>
>> Instead, optimize all_matching_threads_iterator directly to detect these
>> different cases and limiting what we iterate on to just what we need.
>>
>>  - if filter_ptid is minus_one_ptid, do as we do now: filter inferiors
>>    based on filter_target, iterate on all of the matching inferiors'
>>    threads
>>  - if filter_ptid is a pid-only ptid (then a filter_target must
>>    necessarily be given), look up that inferior and iterate on all its
>>    threads
>>  - otherwise, filter_ptid is a thread-specific ptid, so look up that
>>    specific thread and "iterate" only on it
>>
>> For the last case, what was an iteration on all threads of the filter
>> target now becomes a call to find_thread_ptid, which is quite efficient
>> now thanks to inferior::ptid_thread_map.
>>
>> gdb/ChangeLog:
>>
>> 	* thread-iter.h (class all_matching_threads_iterator)
>> 	<all_matching_threads_iterator>: Use default.
>> 	<enum class mode>: New.
>> 	<m_inf, m_thr>: Initialize.
>> 	<m_filter_ptid>: Remove.
>> 	* thread-iter.c (all_matching_threads_iterator::m_inf_matches):
>> 	Don't filter on m_filter_ptid.
>> 	(all_matching_threads_iterator::all_matching_threads_iterator):
>> 	Choose path based on filter_ptid (all threads, all threads of
>> 	inferior, single thread).
>> 	(all_matching_threads_iterator::advance): Likewise.
> 
> OK.
> 

FTR, this caused an internal-error, filed at
https://sourceware.org/bugzilla/show_bug.cgi?id=28086 .

Thanks,
- Tom

  reply	other threads:[~2021-07-14  9:41 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 16:56 [PATCH 00/11] Various thread lists optimizations 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 [this message]
2021-07-13  0:47 ` [PATCH 00/11] Various thread lists optimizations Simon Marchi via Gdb-patches

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=7a178941-a14c-27a5-4d39-4246a5d786f9@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --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