Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Performance optimize large bp_location count
Date: Tue, 13 Oct 2009 18:34:00 -0000	[thread overview]
Message-ID: <m3r5t7jg88.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20090904201706.GA26300@host0.dyn.jankratochvil.net> (Jan 	Kratochvil's message of "Fri, 4 Sep 2009 22:17:06 +0200")

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> Every breakpoint being inserted runs check_duplicates() which was
Jan> quadratic => the whole operation was cubic.  n^3 becomes n^2*log(n)
Jan> by this patch.

n^2*log(n) still seems high, but since it dropped off the profile, then
that is good enough.

I puzzled over the choice of a sorted array here, wondering if there
were perhaps some better data structure.  A bit of rationale and
overview in the patch email would go a long way.

Jan> +  /* Left boundary, right boundary and media element of our binary search.  */
Jan> +  unsigned bc_l, bc_r, bc;

I think s/media/median/

Jan> +  /* Find BC_L which is a leftmost element which may affect BUF content.  It is
Jan> +     safe to report lower value but a failure to report higher one.  */
Jan> +
Jan> +  bc_l = 0;
Jan> +  bc_r = bp_location_count;
Jan> +  while (bc_l + 1 < bc_r)
Jan> +    {
Jan> +      struct bp_location *b;
Jan> +
Jan> +      bc = (bc_l + bc_r) / 2;
Jan> +      b = bp_location[bc];
Jan> +
Jan> +      if (b->address + bp_location_shadow_len_after_address_max >= b->address
Jan> +	  && b->address + bp_location_shadow_len_after_address_max <= memaddr)
Jan> +	bc_l = bc;
Jan> +      else
Jan> +	bc_r = bc;
Jan> +    }

It isn't obvious to me why this finds the leftmost element when there
are multiple overlapping ones.  What am I missing?

Jan> -  cleanups = make_cleanup (do_vec_free, &old_locations);

I think this is the only use of do_vec_free, so that function can be
removed.

Tom


  reply	other threads:[~2009-10-13 18:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04 20:17 Jan Kratochvil
2009-10-13 18:34 ` Tom Tromey [this message]
2009-10-13 22:35   ` Jan Kratochvil
2009-10-14 22:57     ` Tom Tromey
2009-10-25 19:41       ` Jan Kratochvil

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=m3r5t7jg88.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.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