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.