public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Improve performance of Ada name searches
@ 2023-12-06 17:22 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-12-06 17:22 UTC (permalink / raw)
  To: gdb-cvs

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

commit 47cd8fcf54b0ea6b5c4e576e194022500211f06e
Author: Tom Tromey <tromey@adacore.com>
Date:   Fri Nov 10 09:16:17 2023 -0700

    Improve performance of Ada name searches
    
    A user reported that certain operations -- like printing a large
    structure -- could be slow.  I tracked this down to
    ada-lang.c:map_matching_symbols taking an inordinate amount of time.
    Specifically, calls like the one to look for a parallel "__XVZ"
    variable, in ada_to_fixed_type_1, could result in gdb walking over all
    the entries in the cooked index over and over.
    
    Looking into this reveals that
    cooked_index_functions::expand_matching_symbols is not written
    efficiently -- it ignores its "ordered_compare" parameter.  While
    fixing this would be good, it turns out that this entire method isn't
    needed; so this series removes it.
    
    However, the deletion is not done in this patch.  This one, instead,
    fixes the immediate cause of the slowdown, by using
    objfile::expand_symtabs_matching when possible.  This approach is
    faster because it is more selective about which index entries to
    examine.

Diff:
---
 gdb/ada-lang.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1a591567cda..c3a2b2b4384 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5572,8 +5572,16 @@ map_matching_symbols (struct objfile *objfile,
 		      match_data &data)
 {
   data.objfile = objfile;
-  objfile->expand_matching_symbols (lookup_name, domain, global,
-				    is_wild_match ? nullptr : compare_names);
+  if (is_wild_match || lookup_name.ada ().standard_p ())
+    objfile->expand_matching_symbols (lookup_name, domain, global,
+				      is_wild_match ? nullptr : compare_names);
+  else
+    objfile->expand_symtabs_matching (nullptr, &lookup_name,
+				      nullptr, nullptr,
+				      global
+				      ? SEARCH_GLOBAL_BLOCK
+				      : SEARCH_STATIC_BLOCK,
+				      domain, ALL_DOMAIN);
 
   const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
   for (compunit_symtab *symtab : objfile->compunits ())

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-06 17:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-06 17:22 [binutils-gdb] Improve performance of Ada name searches Tom Tromey

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