public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>
Cc: Lancelot SIX <lancelot.six@amd.com>,  <lsix@lancelotsix.com>
Subject: Re: [PATCH] gdb/py-inferior: Keep inferior threads in a map
Date: Tue, 08 Nov 2022 11:12:04 -0700	[thread overview]
Message-ID: <87o7th48p7.fsf@tromey.com> (raw)
In-Reply-To: <20221107184727.2228056-1-lancelot.six@amd.com> (Lancelot SIX via Gdb-patches's message of "Mon, 7 Nov 2022 18:47:27 +0000")

>>>>> "Lancelot" == Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org> writes:

Lancelot> The python code maintains a list of threads for each inferior.  This
Lancelot> list is implemented as a linked list.  When the number of threads grows
Lancelot> high, this implementation can begin to be a performance bottleneck as
Lancelot> finding a particular thread_object in the list has a complexity of O(N).

Thanks for the patch.

Lancelot> -  delete tmp;
Lancelot> +  auto it = inf_obj->threads->find (tp);
Lancelot> +  if (it != inf_obj->threads->end ())
Lancelot> +    {
Lancelot> +      it->second->thread = nullptr;
Lancelot> +      inf_obj->threads->erase (it);

Doesn't the erase implicitly also drop the 'thread' reference?
That is, I don't think the nullptr assignment is needed here.

Lancelot> -      PyTuple_SET_ITEM (tuple, i, thr);
Lancelot> +      PyTuple_SET_ITEM (tuple, i++, thr);

It's better to do the increment separately, in case PyTuple_SET_ITEM is
a macro that evaluates arguments more than once.

Tom

  reply	other threads:[~2022-11-08 18:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 18:47 Lancelot SIX
2022-11-08 18:12 ` Tom Tromey [this message]
2022-11-08 19:47   ` Lancelot SIX
2022-11-08 21:23     ` Tom Tromey
2022-11-08 21:44 ` Simon Marchi
2022-11-09 14:18   ` Lancelot SIX

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=87o7th48p7.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lancelot.six@amd.com \
    --cc=lsix@lancelotsix.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).