No description
Find a file
Simon Marchi c019c04618 gdb/dwarf: make abbrev_table_cache read-through, make it mandatory
This patch implements some performance improvements initially sent as
part of this series [1], but now as a single patch.  There was some push
back from Tom regarding the increased memory usage, but I think that my
solution is still desirable: it makes the code simpler, and I think that
the memory usage it not an issue (the usage is transient and the amount
of memory used by the abbrev tables is relatively low).

As a reminder, here is the problem I'm looking to solve: when using
split DWARF (.dwo files) plus type units, all units inside a .dwo file
(generally one compile unit plus many type units) share the same abbrev
table.  So we end up re-reading that same abbrev tables many times, and
its gets very noticeable in function process_skeletonless_type_units.

cooked_index_worker_debug_info::process_type_units does some work to
avoid this problem, but it only works when everything is in the main
file (not using split DWARF).

Right now, we cache abbrev tables only in specific cases during
indexing, like when one CU imports things from another CU.  My previous
series changed cutu_reader so that it would add any abbrev table it
would read to the abbrev table cache (if it was passed one as a
parameter).  This allowed using a cache in
process_skeletonless_type_units and cut the time down significantly.

This patch goes a bit further in order to simplify cutu_reader even
further:

 - It makes the abbrev table cache read-through, meaning that when you
   request an abbrev table and it's not in the cache, it will go read
   it (and cache it).

 - It makes passing an abbrev table cache to the constructors mandatory
   (even when we wouldn't benefit from using a cache).

The result is that cutu_reader doesn't need to manage multiple cases of
how to obtain an abbrev table, and it doesn't need to manage adding
abbrev tables to the cache.  It no longer needs to manage the ownership
of the abbrev tables either: the abbrev tables are always owned by the
cache.  And the cases of abbrev table sharing are well handled
transparently.

This means that we pay a small price when we don't necessarily need to
(sometimes building and destroying an abbrev_table_cache for just one
cutu_reader), but I think that this price is not significant and the
code simplification is welcome.

In concrete terms, this patch:

 - changes abbrev_table_cache::find to become abbrev_table_cache::get,
   making it read-through
 - removes abbrev_table_cache::add
 - removes the abbrev_table parameter from the main cutu_reader
   constructor
 - makes the abbrev_table_cache parameter mandatory (a reference) in the
   main cutu_reader constructor, adds it to the alternative constructor,
   and passes it down to a few methods
 - adjusts the cutu_reader code obtaining an abbrev table to just call
   abbrev_table_cache::get
 - adjusts all the cutu_reader users to pass an abbrev_table_cache (if
   not already)
 - removes the code in
   cooked_index_worker_debug_info::process_type_units meant to
   efficiently handle TUs that share abbrev tables - the cache now does
   this

The specific split DWARF + type units performance problem at the origin
of this work gets fixed by the fact that
cooked_index_worker_debug_info::process_skeletonless_type_unit now
passes an abbrev table cache to cutu_reader, and
cutu_reader::read_cutu_die_from_dwo uses it.

As a test, I'm using a build of Blender compiled with -gsplit-dwarf and
-fdebug-types-section.  I run this:

    $ ./gdb -nx -q --data-directory=data-directory -ex 'maint set dwarf sync on' -ex 'maintenance set per-command time on' -ex "file /data1/smarchi/blender-build/relwithdebinfo-clang-debugtypes-splitdwarf/bin/blender" -batch

and look at the time taken by the "DWARF skeletonless type units"
step.  Before looks like:

    Time for "DWARF skeletonless type units": wall 11.131, user 10.699, sys 0.431, user+sys 11.130, 100.0 % CPU

and after looks like:

    Time for "DWARF skeletonless type units": wall 1.751, user 1.221, sys 0.518, user+sys 1.739, 99.3 % CPU

The total run time (wall clock time) of the command goes from about 18.5
seconds to about 9.5 seconds.

I removed this assert in cutu_reader, because it relies on abbrev_cache
as a flag for whether we're in the indexer:

      /* If an existing_cu is provided, a dwarf2_cu must not exist for
	 this_cu in per_objfile yet.  Here, CACHE doubles as a flag to
	 let us know that the CU is being scanned using the parallel
	 indexer.  This assert is avoided in this case because (1) it
	 is irrelevant, and (2) the get_cu method is not
	 thread-safe.  */
      gdb_assert (abbrev_cache != nullptr
		  || per_objfile.get_cu (&this_cu) == nullptr);

It's not clear to me if this assert is important or how to implement it
differently.

[1] https://inbox.sourceware.org/gdb-patches/20250326200002.136200-4-simon.marchi@efficios.com/

Change-Id: Idf8a514326fb35be8bda0d7ebe3cee4b7304941a
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-31 22:24:37 -05:00
bfd Automatic date update in version.in 2026-02-01 00:00:07 +00:00
binutils readelf vs. mapping symbols 2026-01-31 07:50:11 +10:30
config tidy m4 plugin config support 2025-11-03 10:59:50 +10:30
contrib [contrib] Accept _("") and operator() in check_GNU_style_lib.py 2025-11-20 10:46:54 +01:00
cpu Add markers for 2.45 branch 2025-07-13 08:35:45 +01:00
elfcpp Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
etc Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
gas include: libsframe: rename SFrame V3 Flexible FDE macros to CTRLWORD 2026-01-29 20:02:57 -08:00
gdb gdb/dwarf: make abbrev_table_cache read-through, make it mandatory 2026-01-31 22:24:37 -05:00
gdbserver gdbserver: Add aarch64-windows support 2026-01-26 19:34:16 +01:00
gdbsupport Introduce character-printing class 2026-01-31 11:38:47 -07:00
gnulib gnulib: re-generate Makefile.in 2026-01-06 15:14:50 -05:00
gold regen pot files 2026-01-28 10:13:02 +10:30
gprof regen gprof and gprofng configure 2026-01-30 07:37:19 +10:30
gprofng update gprofng doc/version.texi 2026-01-30 08:15:26 +10:30
include include: libsframe: rename SFrame V3 Flexible FDE macros to CTRLWORD 2026-01-29 20:02:57 -08:00
ld PR 33629 Fix comment typo in last commit 2026-01-31 12:20:55 +10:30
libbacktrace tidy m4 plugin config support 2025-11-03 10:59:50 +10:30
libctf Update year range in copyright notice of binutils files 2026-01-01 23:22:14 +10:30
libdecnumber regen config 2023-08-12 10:27:57 +09:30
libiberty Regenerate libiberty/aclocal.m4 and ld/config.in using the correct versions of the autotools 2026-01-13 10:04:05 +00:00
libsframe doc: sframe: restore DRAFT marker for all outputs 2026-01-30 12:42:54 -08:00
opcodes Update version now that the 2.46 branch has been created 2026-01-29 11:31:16 +00:00
readline readline/tcap.h: Update definitions for C23 2025-05-02 12:00:05 -06:00
sim sim: re-generate Makefile.in 2026-01-06 15:15:02 -05:00
texinfo
zlib tidy m4 plugin config support 2025-11-03 10:59:50 +10:30
.cvsignore
.editorconfig toplevel: unify the GCC and GDB/binutils .editorconfig files 2025-10-01 16:20:29 +01:00
.gitattributes binutils-gdb/git: Handle *.ac and *.m4 files in .gitattributes 2025-12-18 10:00:54 +01:00
.gitignore Add Vim swap files to .gitignore 2025-02-28 16:06:25 +00:00
.pre-commit-config.yaml Update black to 26.1.0 2026-01-23 06:45:46 -07:00
ar-lib
ChangeLog Import the following commits from the master config sources: a2287c3041a3f2a204eb942e09c015eab00dc7dd 973e3e6af23b73a4f1b8d95680454cae22593bf8 3a71dc102953608d4592ec401b519837c28a672a f91a544533876c70f43b9fd51064b2bcf3fa7382 484648c73f3843b256dd011bd415e81594300a0a 7f4149527babe92cb5da1032734f5cb90cefdac5 9f6e0fe8ce04628bbd4a455118ff3f8309a1aef9 2026-01-08 11:20:38 +00:00
compile
config-ml.in MSP430: Add -fno-exceptions multilib 2023-08-12 10:24:26 +09:30
config.guess Import the following commits from the master config sources: a2287c3041a3f2a204eb942e09c015eab00dc7dd 973e3e6af23b73a4f1b8d95680454cae22593bf8 3a71dc102953608d4592ec401b519837c28a672a f91a544533876c70f43b9fd51064b2bcf3fa7382 484648c73f3843b256dd011bd415e81594300a0a 7f4149527babe92cb5da1032734f5cb90cefdac5 9f6e0fe8ce04628bbd4a455118ff3f8309a1aef9 2026-01-08 11:20:38 +00:00
config.rpath
config.sub Import the following commits from the master config sources: a2287c3041a3f2a204eb942e09c015eab00dc7dd 973e3e6af23b73a4f1b8d95680454cae22593bf8 3a71dc102953608d4592ec401b519837c28a672a f91a544533876c70f43b9fd51064b2bcf3fa7382 484648c73f3843b256dd011bd415e81594300a0a 7f4149527babe92cb5da1032734f5cb90cefdac5 9f6e0fe8ce04628bbd4a455118ff3f8309a1aef9 2026-01-08 11:20:38 +00:00
configure Sync top-level with GCC 2025-11-03 09:53:04 +00:00
configure.ac Sync top-level with GCC 2025-11-03 09:53:04 +00:00
COPYING
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
COPYING3
COPYING3.LIB
depcomp
djunpack.bat
install-sh
libtool.m4 Binutils/GCC: Add clang LTO support to AR, NM and RANLIB 2025-09-25 12:30:13 +08:00
ltgcc.m4
ltmain.sh ltmain.sh: allow more flags at link-time 2024-09-25 19:06:10 +01:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS Fix compiling bfd/vms-lib.c for a 32-bit host. 2024-03-18 10:26:16 +00:00
Makefile.def Sync top-level with GCC 2025-11-03 09:53:04 +00:00
Makefile.in Sync toplevel files from gcc 2025-10-02 07:42:18 +08:00
Makefile.tpl Sync toplevel files from gcc 2025-10-02 07:42:18 +08:00
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README README: don't talk about libg++ 2025-09-07 04:06:01 +01:00
README-maintainer-mode
SECURITY.txt Add a SECURITY.txt file describing the GNU Binutils' project's stance on security related bugs. 2023-04-20 16:52:11 +01:00
setup.com
src-release.sh Rename 'binutils' to 'binutils_with_gold'. Rename 'bin_no_gold' to 'binutils'. Add 'gold' 2025-02-04 11:50:02 +00:00
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README, and so on. That'll give you
info about this package -- supported targets, how to use it, how to report
bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.