public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] Micro-optimize partial_die_info::read
@ 2020-04-02 18:55 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-04-02 18:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

While profiling the DWARF reader, I noticed that
partial_die_info::read creates a vector to store attributes.  However,
the vector is not needed, as this code only processes a single
attribute at a time.

This patch removes the vector.  On my machine, this improves the time
of "./gdb ./gdb" from 2.22 seconds to 1.92 seconds (mean times over 10
runs).

Note that the attribute is initialized by read_attribute, so it does
not need any special initialization.  Avoiding this also improves
performance a bit.

Tested on x86-64 Fedora 30.  I'm checking this in.

gdb/ChangeLog
2020-04-02  Tom Tromey  <tromey@adacore.com>

	* dwarf2/read.c (partial_die_info::read): Do not create a vector
	of attributes.
---
 gdb/ChangeLog     | 5 +++++
 gdb/dwarf2/read.c | 7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index f94c66b4f1b..0df5676c4d3 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -17879,18 +17879,17 @@ partial_die_info::read (const struct die_reader_specs *reader,
   int has_high_pc_attr = 0;
   int high_pc_relative = 0;
 
-  std::vector<struct attribute> attr_vec (abbrev.num_attrs);
   for (i = 0; i < abbrev.num_attrs; ++i)
     {
+      attribute attr;
       bool need_reprocess;
-      info_ptr = read_attribute (reader, &attr_vec[i], &abbrev.attrs[i],
+      info_ptr = read_attribute (reader, &attr, &abbrev.attrs[i],
 				 info_ptr, &need_reprocess);
       /* String and address offsets that need to do the reprocessing have
          already been read at this point, so there is no need to wait until
 	 the loop terminates to do the reprocessing.  */
       if (need_reprocess)
-	read_attribute_reprocess (reader, &attr_vec[i]);
-      attribute &attr = attr_vec[i];
+	read_attribute_reprocess (reader, &attr);
       /* Store the data if it is of an attribute we want to keep in a
          partial symbol table.  */
       switch (attr.name)
-- 
2.21.1


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

only message in thread, other threads:[~2020-04-02 18:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 18:55 [pushed] Micro-optimize partial_die_info::read 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).