From patchwork Wed Oct 12 13:50:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 119207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id CE07EB6F7C for ; Thu, 13 Oct 2011 00:50:43 +1100 (EST) Received: (qmail 16015 invoked by alias); 12 Oct 2011 13:50:37 -0000 Received: (qmail 15999 invoked by uid 22791); 12 Oct 2011 13:50:36 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_GD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 12 Oct 2011 13:50:13 +0000 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 p9CDoCmb001505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Oct 2011 09:50:13 -0400 Received: from host1.jankratochvil.net (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9CDoAMc028760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 12 Oct 2011 09:50:12 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p9CDo9mZ025676 for ; Wed, 12 Oct 2011 15:50:09 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p9CDo9rE025675 for gcc-patches@gcc.gnu.org; Wed, 12 Oct 2011 15:50:09 +0200 Date: Wed, 12 Oct 2011 15:50:08 +0200 From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Subject: [patch] dwarf2out: Drop the size + performance overhead of DW_AT_sibling Message-ID: <20111012135008.GA24037@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, dropping the optional DWARF attribute DW_AT_sibling has only advantages and no disadvantages: For files with .gdb_index GDB initial scan does not use DW_AT_sibling at all. For files without .gdb_index GDB initial scan has 1.79% time _improvement_. For .debug files it brings 3.49% size decrease (7.84% for rpm compressed files). I guess DW_AT_sibling had real performance gains on CPUs with 1x (=no) clock multipliers. Nowadays mostly only the data size transferred over FSB matters. I do not think there would be any DWARF consumers compatibility problems as DW_AT_sibling has always been optional but I admit I have tested only GDB. "clean" is FSF GCC+GDB, "ns" is FSF GCC with the patch applied. gdbindex -readnow 100x warm: clean: 56.975 57.161 57.738 58.243 57.52924999999999 seconds ns: 57.799 58.008 58.202 58.473 58.120499999999993 seconds +1.03% = performance decrease but it should be 0%, it is a measurement error gdbindex -readnow 20x warm(gdb) cold(data): clean: 57.989 ns: 58.538 +0.95% = performance decrease but it should be 0%, it is a measurement error 200x warm: clean: 14.393 14.414 14.587 14.496 14.472499999999998 seconds ns: 14.202 14.160 14.174 14.318 14.213499999999998 seconds -1.79% = performance improvement of non-gdbindex scan (dwarf2_build_psymtabs_hard) gdbindex .debug: clean = 5589272 bytes ns = 5394120 bytes -3.49% = size improvement gdbindex .debug.xz9: clean = 1158696 bytes ns = 1067900 bytes -7.84% = size improvement .debug_info + .debug_types: clean = 0x1a11a0+0x08f389 bytes ns = 0x184205+0x0833b0 bytes -7.31% = size improvement Intel i7-920 CPU and only libstdc++ from GCC 4.7.0 20111002 and `-O2 -gdwarf-4 -fdebug-types-section' were used for the benchmark. GCC 4.7.0 20111002 --enable-languages=c++ was used for `make check' regression testing. Thanks, Jan gcc/ 2011-10-12 Jan Kratochvil Stop producing DW_AT_sibling. * dwarf2out.c (add_sibling_attributes): Remove the declaration. (add_sibling_attributes): Remove the function. (dwarf2out_finish): Remove calls of add_sibling_attributes. --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -3316,7 +3316,6 @@ static int htab_cu_eq (const void *, const void *); static void htab_cu_del (void *); static int check_duplicate_cu (dw_die_ref, htab_t, unsigned *); static void record_comdat_symbol_number (dw_die_ref, htab_t, unsigned); -static void add_sibling_attributes (dw_die_ref); static void build_abbrev_table (dw_die_ref); static void output_location_lists (dw_die_ref); static int constant_size (unsigned HOST_WIDE_INT); @@ -7482,24 +7481,6 @@ copy_decls_for_unworthy_types (dw_die_ref unit) unmark_dies (unit); } -/* Traverse the DIE and add a sibling attribute if it may have the - effect of speeding up access to siblings. To save some space, - avoid generating sibling attributes for DIE's without children. */ - -static void -add_sibling_attributes (dw_die_ref die) -{ - dw_die_ref c; - - if (! die->die_child) - return; - - if (die->die_parent && die != die->die_parent->die_child) - add_AT_die_ref (die, DW_AT_sibling, die->die_sib); - - FOR_EACH_CHILD (die, c, add_sibling_attributes (c)); -} - /* Output all location lists for the DIE and its children. */ static void @@ -22496,14 +22477,6 @@ dwarf2out_finish (const char *filename) prune_unused_types (); } - /* Traverse the DIE's and add add sibling attributes to those DIE's - that have children. */ - add_sibling_attributes (comp_unit_die ()); - for (node = limbo_die_list; node; node = node->next) - add_sibling_attributes (node->die); - for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next) - add_sibling_attributes (ctnode->root_die); - /* Output a terminator label for the .text section. */ switch_to_section (text_section); targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);