]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Finalize each cooked index separately
authorTom Tromey <tromey@adacore.com>
Fri, 13 May 2022 19:46:52 +0000 (13:46 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 26 May 2022 13:35:30 +0000 (07:35 -0600)
commit20a26f4e018cd0cb40a3b81568be0d4f164eed0f
tree28ffe28aa1e3eef2791afa1ff7c2fb368091661e
parentf420c9c84eb53fea7da452eab8ae0bd855537859
Finalize each cooked index separately

After DWARF has been scanned, the cooked index code does a
"finalization" step in a worker thread.  This step combines all the
index entries into a single master list, canonicalizes C++ names, and
splits Ada names to synthesize package names.

While this step is run in the background, gdb will wait for the
results in some situations, and it turns out that this step can be
slow.  This is PR symtab/29105.

This can be sped up by parallelizing, at a small memory cost.  Now
each index is finalized on its own, in a worker thread.  The cost
comes from name canonicalization: if a given non-canonical name is
referred to by multiple indices, there will be N canonical copies (one
per index) rather than just one.

This requires changing the users of the index to iterate over multiple
results.  However, this is easily done by introducing a new "chained
range" class.

When run on gdb itself, the memory cost seems rather low -- on my
current machine, "maint space 1" reports no change due to the patch.

For performance testing, using "maint time 1" and "file" will not show
correct results.  That approach measures "time to next prompt", but
because the patch only affects background work, this shouldn't (and
doesn't) change.  Instead, a simple way to make gdb wait for the
results is to set a breakpoint.

Before:

    $ /bin/time -f%e ~/gdb/install/bin/gdb -nx -q -batch \
        -ex 'break main' /tmp/gdb
    Breakpoint 1 at 0x43ec30: file ../../binutils-gdb/gdb/gdb.c, line 28.
    2.00

After:

    $ /bin/time -f%e ./gdb/gdb -nx -q -batch \
        -ex 'break main' /tmp/gdb
    Breakpoint 1 at 0x43ec30: file ../../binutils-gdb/gdb/gdb.c, line 28.
    0.65

Regression tested on x86-64 Fedora 34.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29105
gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdbsupport/range-chain.h [new file with mode: 0644]