--- Begin Message ---
- From: Tom Tromey <tromey at redhat dot com>
- To: GDB Development <gdb at sourceware dot org>
- Date: Fri, 09 Mar 2012 13:17:11 -0700
- Subject: FYI: micro-optimize producer checks
- Approved: news@gmane.org
- Archived-at: <http://permalink.gmane.org/gmane.comp.gdb.devel/31793>
- 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=1331929057; 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=nvtRpi8+zns5+g5ylYvktl+BDL0=; b=KTzhoGlkiuscp/mLVSNWRYmA/GR/RfnsIj7VdXFjIDMmT9/Mxhl8lhoVdUhKnyTfejfDsP5b+oMLv24l5QiX3B6fGi8gcl85YjdYK0OKZUxcLiDtvGcYoy341RNHOUoki/XfjfQSFU7fkKeycKyRNrJFqhtajg8qz2nPv4OldVU=
- 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=ZpDP5w/pwARe9ZYURAyalnfS8+bw9ICsgzlzh/pGrvUKI7pY6R2qCDtYnm/Hd2LO6k0TxNz+GtIY1P0XUr3bDH3Wqzfx7euMWaEPjSZb1gJ0OmfJOCM0batSS/aydRsdCUXmb9EuLP7Vl/IlNHNhT7XdJzQfvwjZrgWW0O7al70=;
- 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-40549-gdb-gdb=m.gmane.org@sourceware.org>)id 1S66Ft-0000n5-6ofor gdb-gdb@plane.gmane.org; Fri, 09 Mar 2012 21:17:37 +0100
- Original-received: (qmail 25180 invoked by alias); 9 Mar 2012 20:17:33 -0000
- Original-received: (qmail 25161 invoked by uid 22791); 9 Mar 2012 20:17:30 -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:17:13 +0000
- Original-received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q29KHDke008950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for <gdb@sourceware.org>; Fri, 9 Mar 2012 15:17:13 -0500
- Original-received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q29KHC5o012829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 9 Mar 2012 15:17:12 -0500
- Original-x-from: gdb-return-40549-gdb-gdb=m.gmane.org@sourceware.org Fri Mar 09 21:17:37 2012
- Xref: news.gmane.org gmane.comp.gdb.devel:31793
I'm checking this in.
This is a second CU expansion performance micro-optimization.
As before, my test case was 'gdb -batch -readnow gdb'.
I neglected to mention in the earlier note that these tests and numbers
were done with a default ("-g -O2") build of gdb, using the Fedora 16
system gcc.
If you instead use '-g3', you will also see a big slowdown from a call
to complaint (!) in dwarf_decode_macro_bytes (it is actually dcgettext
which shows up in the profile). This is related to a gcc bug (I
surmise, I didn't dig into it); but regardless, I think that this means
that the complaint system in gdb needs a fix. I didn't do this today,
though.
Anyway. I was surprised to find that gdb was spending a fair amount of
time in sscanf during CU expansion. This was caused by repeated calls
to producer_is_gxx_lt_4_6.
The fix is to cache this information. This is space-neutral but takes
us from 2:36 to 2:23 on the test case. This is another 5% improvement.
Built and regtested on x86-64 Fedora 16.
Tom
2012-03-09 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (struct dwarf2_cu) <checked_producer,
producer_is_gxx_lt_4_6>: New fields.
(producer_is_gxx_lt_4_6): Use and update producer cache fields.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.621
diff -u -r1.621 dwarf2read.c
--- dwarf2read.c 9 Mar 2012 20:06:18 -0000 1.621
+++ dwarf2read.c 9 Mar 2012 20:13:10 -0000
@@ -383,6 +383,13 @@
any location list and still facing inlining issues if handled as
unoptimized code. For a future better test see GCC PR other/32998. */
unsigned int has_loclist : 1;
+
+ /* These cache the results of producer_is_gxx_lt_4_6.
+ CHECKED_PRODUCER is set if PRODUCER_IS_GXX_LT_4_6 is valid. This
+ information is cached because profiling CU expansion showed
+ excessive time spent in producer_is_gxx_lt_4_6. */
+ unsigned int checked_producer : 1;
+ unsigned int producer_is_gxx_lt_4_6 : 1;
};
/* Persistent data held for a compilation unit, even when not
@@ -6826,6 +6833,7 @@
{
const char *cs;
int major, minor, release;
+ int result = 0;
if (cu->producer == NULL)
{
@@ -6841,26 +6849,33 @@
return 0;
}
+ if (cu->checked_producer)
+ return cu->producer_is_gxx_lt_4_6;
+
/* Skip any identifier after "GNU " - such as "C++" or "Java". */
if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0)
{
/* For non-GCC compilers expect their behavior is DWARF version
compliant. */
-
- return 0;
}
- cs = &cu->producer[strlen ("GNU ")];
- while (*cs && !isdigit (*cs))
- cs++;
- if (sscanf (cs, "%d.%d.%d", &major, &minor, &release) != 3)
+ else
{
- /* Not recognized as GCC. */
-
- return 0;
+ cs = &cu->producer[strlen ("GNU ")];
+ while (*cs && !isdigit (*cs))
+ cs++;
+ if (sscanf (cs, "%d.%d.%d", &major, &minor, &release) != 3)
+ {
+ /* Not recognized as GCC. */
+ }
+ else
+ result = major < 4 || (major == 4 && minor < 6);
}
- return major < 4 || (major == 4 && minor < 6);
+ cu->checked_producer = 1;
+ cu->producer_is_gxx_lt_4_6 = result;
+
+ return result;
}
/* Return the default accessibility type if it is not overriden by
--- End Message ---