Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aditya Kamath <Aditya.Kamath1@ibm.com>
To: Simon Marchi <simon.marchi@polymtl.ca>,
	Aditya Vidyadhar Kamath <akamath996@gmail.com>,
	Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	"tom@tromey.com" <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	SANGAMESH MALLAYYA <sangamesh.swamy@in.ibm.com>
Subject: RE: [PATCH v3 3/3][RFC] Speed up next/step while debugging multithreaded programs on AIX.
Date: Tue, 22 Sep 2026 13:21:57 +0000	[thread overview]
Message-ID: <DSWPR15MB3198175BF4FE200243EEA9A475D6832@DSWPR15MB319817.namprd15.prod.outlook.com> (raw)
In-Reply-To: <acfea0a3-20ba-4737-a88f-a337afebe083@polymtl.ca>

[-- Attachment #1: Type: text/plain, Size: 2938 bytes --]

Hi Simon, Ulrich and community members,


>Again, I am not sure that's true.  There is certainly one single
>instruction (possibly a syscall) inside pthread_create that commits the
>thread creation, after which the new thread will be visible.  If you
>single-step that instruction, you'll have one more thread after stepping
>than you had before.

>And with "set scheduler-locking off", threads other than the one being
>stepped run freely during the step.  One of those threads could exit
>during your instruction single step, so you'd miss that.

>If you know that new threads can only appear during a syscall
>instruction (I have no idea, just speculating), then you could perhaps
>check what is the instruction about to be stepped.  If it's not a
>syscall instruction, and if the scheduler-locking setting is "on” or
>"step" (nothing else than this thread will run during the step), then
>perhaps it would be safe to skip the thread update.  But you'd have to
>check how it really works under the hood.


So, from the scoped_time_it instrumentation instrumentation pthdb_pthread, sync_threadlists, pd_update costs 1.2 seconds roughly in my LPAR. get_signaled_thread, pthdb_pthread_state, pthdb_pthread_tid, pthdb_pthread_ptid, pthdb_session_update are all free. They hardly cost anything.


The very first pthdb_pthread(PTHDB_LIST_FIRST) call inside sync_threadlists costs ~1 second per stop regardless of thread count (same cost with 3 threads as with 20). Everything else is essentially free. That one call is what libpthdebug uses to start enumerating threads, what I mean is it walks all the pthread internal data structures in the inferior process. Skipping sync_threadlists entirely on step stops eliminates that cost completely, giving the 4.2X speedup.

As you noted, stepping over the instruction that commits a pthread_create (or observing another thread exit when scheduler-locking off is in effect) could cause the thread state to change while the step is in progress. So skipping the update unconditionally for every software single-step would not be correct.

However, as you pointed out, doing so unconditionally is not correct. If a step executes the instruction that makes a newly created thread visible, or if another thread exits while scheduler-locking off is in effect, then the thread list can legitimately change during the step. In those cases, skipping the update would cause GDB to miss thread creation and/or thread termination events. I have not yet found a reliable way to avoid this. Now it appears that the real bottleneck is the cost of pthdb_pthread(PTHDB_LIST_FIRST) itself rather than any of the surrounding GDB logic. Given that, I will discuss this with the AIX maintainers to understand better opportunities for improvement. Thanks again for the review and for highlighting the correctness concerns.

Have a nice day ahead.

Thanks and regards,

Aditya.




[-- Attachment #2: Type: text/html, Size: 11278 bytes --]

      reply	other threads:[~2026-09-22 13:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 11:49 Aditya Vidyadhar Kamath
2026-09-16 19:06 ` Simon Marchi
2026-09-22 13:21   ` Aditya Kamath [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=DSWPR15MB3198175BF4FE200243EEA9A475D6832@DSWPR15MB319817.namprd15.prod.outlook.com \
    --to=aditya.kamath1@ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=akamath996@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.com \
    /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