From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 1636B388A037 for ; Thu, 2 Apr 2020 18:55:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1636B388A037 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BBA6C11629B; Thu, 2 Apr 2020 14:55:26 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 99KvNxxkHFYW; Thu, 2 Apr 2020 14:55:26 -0400 (EDT) Received: from murgatroyd.Home (174-16-110-145.hlrn.qwest.net [174.16.110.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 78F3C116289; Thu, 2 Apr 2020 14:55:26 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Micro-optimize partial_die_info::read Date: Thu, 2 Apr 2020 12:55:24 -0600 Message-Id: <20200402185524.15942-1-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-22.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2020 18:55:28 -0000 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 * 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 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