--- Begin Message ---
- From: Tom Tromey <tromey at redhat dot com>
- To: GDB Development <gdb at sourceware dot org>
- Date: Fri, 09 Mar 2012 13:05:54 -0700
- Subject: FYI: micro-optimize dwarf2_attr
- Approved: news@gmane.org
- Archived-at: <http://permalink.gmane.org/gmane.comp.gdb.devel/31792>
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed;d=sourceware.org; s=default; x=1331928386; h=Comment:DomainKey-Signature:Received:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=Y1MPL4EwEojsSYB4G5SccWbsN6o=; b=gGEOZ2nHcQUjiXqbjdf7cptTvFnlFnmOtUYw2oV85oyDpSmKdbnw/KcN/19TK+mI9pCMhoge+nVX1kkOSa5pc0vsCKunaa/4egsG24KENjz71j6qkcfKa0gdY4VkPAR/WJuhjneQ9FWj8K4p7f61fS6sHnxkWG1JzyrpN64AFug=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws;s=default; d=sourceware.org;h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To;b=ZueICWK4DyeKudCMS+fvS3kL+qzCl/r7hxjHdWvgOEtkiTSyxpQlX/xQucRenNKn2UB86PdVxlhlrtrZLrcKTTquskcNWMubNVE2UIikpwYEw9Kb5kwJdDyUQrNhulEPvMrihWa7Q9Co5fVlGRyZj2yputO/nNKri0F3O79hBCo=;
- Envelope-to: gdb-gdb@plane.gmane.org
- Newsgroups: gmane.comp.gdb.devel
- Original-received: from server1.sourceware.org ([209.132.180.131] helo=sourceware.org)by plane.gmane.org with smtp (Exim 4.69)(envelope-from <gdb-return-40548-gdb-gdb=m.gmane.org@sourceware.org>)id 1S6654-0002S0-ISfor gdb-gdb@plane.gmane.org; Fri, 09 Mar 2012 21:06:26 +0100
- Original-received: (qmail 18800 invoked by alias); 9 Mar 2012 20:06:11 -0000
- Original-received: (qmail 18752 invoked by uid 22791); 9 Mar 2012 20:06:09 -0000
- Original-received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Mar 2012 20:05:56 +0000
- Original-received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q29K5utG029417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for <gdb@sourceware.org>; Fri, 9 Mar 2012 15:05:56 -0500
- Original-received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q29K5sfM027964 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 9 Mar 2012 15:05:55 -0500
- Original-x-from: gdb-return-40548-gdb-gdb=m.gmane.org@sourceware.org Fri Mar 09 21:06:32 2012
- Xref: news.gmane.org gmane.comp.gdb.devel:31792
I'm checking this in.
I was curious about CU expansion performance and I did a little
profiling today. Normally CU expansion is not worth worrying about, but
we have found a few cases where it hurts; and so it makes sense to care
about it.
My test case was 'gdb -batch -readnow gdb'.
I reasoned (correctly) that this would be dominated by the time to
expand CUs.
This yielded a few surprises, which I have micro-optimized away.
First, dwarf2_attr can be fixed to avoid a tail-recursive call.
This reduced the time for the test case from 2.51 to 2.36.
That is about a 6% savings.
Built and regtested on x86-64 Fedora 16.
Tom
2012-03-09 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf2_attr): Avoid tail-recursive call.
>From fa665e1aab150b3e345e8ded4219791d99ed0edb Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Fri, 9 Mar 2012 12:32:55 -0700
Subject: [PATCH 1/2] micro-optimize dwarf2_attr
---
gdb/dwarf2read.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 6eed8d5..9133178 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10708,22 +10708,24 @@ set_cu_language (unsigned int lang, struct dwarf2_cu *cu)
static struct attribute *
dwarf2_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu)
{
- unsigned int i;
- struct attribute *spec = NULL;
-
- for (i = 0; i < die->num_attrs; ++i)
+ for (;;)
{
- if (die->attrs[i].name == name)
- return &die->attrs[i];
- if (die->attrs[i].name == DW_AT_specification
- || die->attrs[i].name == DW_AT_abstract_origin)
- spec = &die->attrs[i];
- }
+ unsigned int i;
+ struct attribute *spec = NULL;
+
+ for (i = 0; i < die->num_attrs; ++i)
+ {
+ if (die->attrs[i].name == name)
+ return &die->attrs[i];
+ if (die->attrs[i].name == DW_AT_specification
+ || die->attrs[i].name == DW_AT_abstract_origin)
+ spec = &die->attrs[i];
+ }
+
+ if (!spec)
+ break;
- if (spec)
- {
die = follow_die_ref (die, spec, &cu);
- return dwarf2_attr (die, name, cu);
}
return NULL;
--
1.7.7.6
--- End Message ---