public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/14340] New: rbreak inefficiency
@ 2012-07-08 19:46 dje at google dot com
  2012-07-09 19:32 ` [Bug breakpoints/14340] " tromey at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dje at google dot com @ 2012-07-08 19:46 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14340

             Bug #: 14340
           Summary: rbreak inefficiency
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned@sourceware.org
        ReportedBy: dje@google.com
    Classification: Unclassified


rbreak_command first calls search_symbols to collect the list of symbols that
match the regexp (or file:regexp).  It then loops over each found symbol
calling, essentially, "break file:function" which in turn causes gdb to loop
over all symtabs again, but this time for each symtab:symbol from the result of
search_symbols.

Perhaps there's a reason why the code is the way it is, but it's odd that the
result of search_symbols isn't sufficient.
There's a massive speedup to be had by having a breakpoint API routine that
takes a struct symbol as an argument.

Presumably I'm missing something, but I'm not sure what it is.

[sidebar: it's odd that struct symbol_search records symtab even though one can
get the symbol's symtab from struct symbol]

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug breakpoints/14340] rbreak inefficiency
  2012-07-08 19:46 [Bug breakpoints/14340] New: rbreak inefficiency dje at google dot com
@ 2012-07-09 19:32 ` tromey at redhat dot com
  2024-12-11 17:28 ` tromey at sourceware dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2012-07-09 19:32 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14340

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2012-07-09 19:32:25 UTC ---
(In reply to comment #0)
> rbreak_command first calls search_symbols to collect the list of symbols that
> match the regexp (or file:regexp).  It then loops over each found symbol
> calling, essentially, "break file:function" which in turn causes gdb to loop
> over all symtabs again, but this time for each symtab:symbol from the result of
> search_symbols.

There's also a further quadratic slowdown by checking for duplicate locations.
You can see it clearly if you "rbreak .*" on gdb itself.
I think this is a reasonable-enough scenario that it ought to work.

> Perhaps there's a reason why the code is the way it is, but it's odd that the
> result of search_symbols isn't sufficient.
> There's a massive speedup to be had by having a breakpoint API routine that
> takes a struct symbol as an argument.

Keith is working on something similar to this, though not identical.

Another approach would be to have rbreak create a single breakpoint with
a "regexp linespec" instead of having rbreak create multiple breakpoints.
Doing this efficiently would require the fine-grained breakpoint re-setting
work that we plan, but haven't yet done.

> [sidebar: it's odd that struct symbol_search records symtab even though one can
> get the symbol's symtab from struct symbol]

I wonder whether symbol::symtab was added later.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug breakpoints/14340] rbreak inefficiency
  2012-07-08 19:46 [Bug breakpoints/14340] New: rbreak inefficiency dje at google dot com
  2012-07-09 19:32 ` [Bug breakpoints/14340] " tromey at redhat dot com
@ 2024-12-11 17:28 ` tromey at sourceware dot org
  2024-12-16 18:18 ` cvs-commit at gcc dot gnu.org
  2024-12-16 18:20 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2024-12-11 17:28 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14340

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org
           Assignee|unassigned at sourceware dot org   |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
I ran across this and fixed it, but forgot about this bug:
https://sourceware.org/pipermail/gdb-patches/2024-June/209954.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug breakpoints/14340] rbreak inefficiency
  2012-07-08 19:46 [Bug breakpoints/14340] New: rbreak inefficiency dje at google dot com
  2012-07-09 19:32 ` [Bug breakpoints/14340] " tromey at redhat dot com
  2024-12-11 17:28 ` tromey at sourceware dot org
@ 2024-12-16 18:18 ` cvs-commit at gcc dot gnu.org
  2024-12-16 18:20 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-12-16 18:18 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14340

--- Comment #3 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3d6744493634e704b6977924a0cc8082886523f5

commit 3d6744493634e704b6977924a0cc8082886523f5
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Jun 6 09:42:15 2024 -0600

    Greatly speed up rbreak

    While debugging another issue, I noticed that 'rbreak' on a large
    program was very slow.  In particular, with 'maint time 1':

    (gdb) with pagination off -- rbreak ^command_display
    [...]
    Command execution time: 1940.646332 (cpu), 1960.771517 (wall)

    "ps" also reported that, after this command, gdb's VSZ was 4619360.

    Looking into this, I found something strange.  When 'rbreak' found a
    function "f" in file "file.adb", it would try to set the breakpoint
    using "break 'file.adb':'f'".

    This then interacted somewhat poorly with linespec.  linespec first
    expands all the symtabs matching "file.adb", but in this program this
    results in thousands of CU expansions (probably due to inlining, but I
    did not investigate).

    There is probably a linespec bug here.  It would make more sense for
    it to combine the file- and symbol- lookups, as this is more
    efficient.  I plan to file a bug about this at least.

    I tracked this "file:function" style of linespec to the earliest days
    of gdb.  Back then, "break function" would only break on the first
    "function" that was found -- it wasn't until much later that we
    changed gdb to break on all matching functions.  So, I think that
    rbreak was written this way to try to work around this limitation, and
    it seems to me that this change obsoleted the need for rbreak to
    mention the file at all.

    That is, "break file:function" is redundant now, because plain
    "break function" will redo that same work -- just more efficiently.
    (The only exception to this is the case where a file is given
    to rbreak -- here the extra filtering is still needed.)

    This patch implements this.  On the aforementioned large program, with
    this patch, rbreak still sets all the desired breakpoints (879 of
    them) but is now much faster:

    (gdb) with pagination off -- rbreak ^command_display
    [...]
    Command execution time: 91.702648 (cpu), 92.770430 (wall)

    It also reduces the VSZ number to 2539216.

    Regression tested on x86-64 Fedora 40.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14340
    Approved-By: Pedro Alves <pedro@palves.net>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug breakpoints/14340] rbreak inefficiency
  2012-07-08 19:46 [Bug breakpoints/14340] New: rbreak inefficiency dje at google dot com
                   ` (2 preceding siblings ...)
  2024-12-16 18:18 ` cvs-commit at gcc dot gnu.org
@ 2024-12-16 18:20 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2024-12-16 18:20 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14340

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |16.1

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-12-16 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-08 19:46 [Bug breakpoints/14340] New: rbreak inefficiency dje at google dot com
2012-07-09 19:32 ` [Bug breakpoints/14340] " tromey at redhat dot com
2024-12-11 17:28 ` tromey at sourceware dot org
2024-12-16 18:18 ` cvs-commit at gcc dot gnu.org
2024-12-16 18:20 ` tromey at sourceware dot org

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).