[Converted from Gnats 2230] When setting a large number of breakpoints, breakpoint handling slows down considerably. For example, when setting 50000 breakpoints (via a program, all by "tbreak *addr" with unique addresses), the first 10000 breakpoints are set reasonably fast (about 10s), but the whole 50000 breakpoints take about 8m. Probably a data structure does not scale. While I noticed it for generated breakpoints on addressses, in occurs on more traditional breakpoints, too. See "How-To-Repeat" for an example. Release: GNU gdb 6.6 Environment: Linux jaiman 2.6.17-11-generic #2 SMP Thu Feb 1 18:03:05 UTC 2007 x86_64 GNU/Linux gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5) This GDB was configured as "x86_64-unknown-linux-gnu". How-To-Repeat: Execute the following script (also attached): #!/bin/sh echo 'int main() { int a=0;' > foo.c for line in `seq 1 50000` ; do echo '++a;' ; done >> foo.c echo '}' >> foo.c gcc -o foo -g -O0 foo.c echo 'set height 100000' > breakpoints for line in `seq 1 50000` ; do echo tbreak foo.c:$line ; done >> breakpoints time gdb foo -batch -x breakpoints It tries to set 50000 different breakpoints, which takes quite a while.
From: Thomas Neumann <tneumann@users.sourceforge.net> To: gdb-gnats@sources.redhat.com Cc: Subject: Re: breakpoints/2230: gdb does not handle a large number of breakpoints gracefully Date: Mon, 19 Feb 2007 00:21:56 +0100 The slowdown is primarily caused by bp_location_chain in gdb/breakpoint.c. It consists of a linear list of all breakpoins, which is scanned for duplicates for each new breakpoint. Experimentally changing it from a list to a splay tree (organized by address) reduces the runtime for the test case from 8 minutes to 2 minutes. Not exactly instantaneous, but much better. Now the hot spot is find_line_common.
Your patch sounds worthwhile to me. If you still have it, would you consider submitting it? Here's some info on how to submit: http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/src/gdb/CONTRIBUTE?content-type=text/x-cvsweb-markup&cvsroot=src
Subject: Re: gdb does not handle a large number of breakpoints gracefully I fear I lost it at some point in the last two years... But I think the change was simple, I just rused some functions from libiberty. Should I try to re-construct the patch? I have a copyright assignment in place for gcc, but not for gdb, it might be simpler for you to just implement it yourself. The patch was really small, if you grep for bp_location_chain you see that it is only used in 7 places.
Posted: http://sourceware.org/ml/gdb-patches/2009-09/msg00105.html
This was checked in a while ago.