From patchwork Fri Feb 21 12:48:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 322660 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DAA722C031A for ; Fri, 21 Feb 2014 23:49:47 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=jYQEJvdvwIiF5Qrt Y1c3Ku2Hsr6w9V4jcKSA3rrbAnDJvCyFQLFMfqmsg7AZWascy7rfUwuCEHWtIF7o zDIigW7cmwIxTYrxRtBGFS5gX76pNUtF50eIy6L1Ii5cnOXrCh+JVp/zt8+RR4g/ 6ZS9h1VLIO4xP/D0JxxOjg9Y9Hc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=TSLKlgsNbLulv5gaRH4eLB 0szoc=; b=UwHdKheGttDD0gnyK/jS0yp2KNU6s2+/Mt20wSw12Qfm9ljpyzapCR bDN7fnrhifjE8AIe9b+UJbdubkMZ5fKX7OABOnCWr9kKrM6fqLbgfyKgh1jyceQG AXJU4nWMM6jVCPO4WkdDpCRbKoPk7UcxEAMoUbVjYNmTC27e5Tw9o= Received: (qmail 13374 invoked by alias); 21 Feb 2014 12:49:41 -0000 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 Received: (qmail 13361 invoked by uid 89); 21 Feb 2014 12:49:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 21 Feb 2014 12:49:39 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4F0ECAC92; Fri, 21 Feb 2014 12:49:36 +0000 (UTC) Date: Fri, 21 Feb 2014 13:48:35 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek , Michael Matz Subject: Re: [PATCH][2/2] Fix expansion slowness of PR60291 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 On Fri, 21 Feb 2014, Richard Biener wrote: > On Fri, 21 Feb 2014, Richard Biener wrote: > > > Last statistics: http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01784.html > > With the patch below to get some statistics we see that one important > piece of sharing not covered by above measurements is RTX copying(?). > > On the testcase for this PR I get at -O1 and without the patch > to clear the hashtable after each function > > 142489 mem_attrs created (142439 for new, 50 for modification) > 1983225 mem_attrs shared (4044 for new, 820241 for modification, 1158940 > by rtx copying) > 0 mem_attrs dropped > > and with the patch to clear after each function > > 364411 mem_attrs created (144478 for new, 219933 for modification) > 1761303 mem_attrs shared (2005 for new, 600358 for modification, 1158940 > by rtx copying) > 0 mem_attrs dropped > > while for dwarf2out.c I see without the clearing > > 24399 mem_attrs created (6929 for new, 17470 for modification) > 102676 mem_attrs shared (10878 for new, 29265 for modification, 62533 by > rtx copying) > 16 mem_attrs dropped Oh, and more than half of shared-modified are actually not modified so are false sharing reports (set_mem_attrs (mem, MEM_ATTRS (mem))). 24399 mem_attrs created (6929 for new, 17470 for modification) 85801 mem_attrs shared (10878 for new, 12390 for modification, 62533 by rtx copying) 16 mem_attrs dropped when dropping sharing completely you "win" creations for modification but lose shares for "new" and "copy". Losing the "copy" case makes it a loss overall which you can eventually offset by using a ref-counting scheme (or better by avoiding copying the MEM in the first place, a MEM is currently 24 bytes while its attrs are 40 bytes). Richard. Index: gcc/rtl.c =================================================================== --- gcc/rtl.c (revision 207938) +++ gcc/rtl.c (working copy) @@ -326,6 +326,8 @@ copy_rtx (rtx orig) return copy; } +unsigned long mem_attrs_shared_copy; + /* Create a new copy of an rtx. Only copy just one level. */ rtx @@ -333,6 +335,8 @@ shallow_copy_rtx_stat (const_rtx orig ME { const unsigned int size = rtx_size (orig); rtx const copy = ggc_alloc_rtx_def_stat (size PASS_MEM_STAT); + if (MEM_P (orig) && MEM_ATTRS (orig)) + mem_attrs_shared_copy++; return (rtx) memcpy (copy, orig, size); } Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c (revision 207938) +++ gcc/emit-rtl.c (working copy) @@ -290,6 +290,12 @@ mem_attrs_htab_eq (const void *x, const return mem_attrs_eq_p ((const mem_attrs *) x, (const mem_attrs *) y); } +unsigned long mem_attrs_dropped; +unsigned long mem_attrs_new; +unsigned long mem_attrs_new_modified; +unsigned long mem_attrs_shared; +unsigned long mem_attrs_shared_modified; + /* Set MEM's memory attributes so that they are the same as ATTRS. */ static void @@ -300,6 +306,8 @@ set_mem_attrs (rtx mem, mem_attrs *attrs /* If everything is the default, we can just clear the attributes. */ if (mem_attrs_eq_p (attrs, mode_mem_attrs[(int) GET_MODE (mem)])) { + if (MEM_ATTRS (mem)) + mem_attrs_dropped++; MEM_ATTRS (mem) = 0; return; } @@ -309,6 +317,20 @@ set_mem_attrs (rtx mem, mem_attrs *attrs { *slot = ggc_alloc_mem_attrs (); memcpy (*slot, attrs, sizeof (mem_attrs)); + if (MEM_ATTRS (mem)) + mem_attrs_new_modified++; + else + mem_attrs_new++; + } + else + { + if (MEM_ATTRS (mem)) + { + if (MEM_ATTRS (mem) != *slot) + mem_attrs_shared_modified++; + } + else + mem_attrs_shared++; } MEM_ATTRS (mem) = (mem_attrs *) *slot; Index: gcc/toplev.c =================================================================== --- gcc/toplev.c (revision 207938) +++ gcc/toplev.c (working copy) @@ -1989,6 +2023,26 @@ toplev_main (int argc, char **argv) if (!exit_after_options) do_compile (); + { + extern unsigned long mem_attrs_dropped; + extern unsigned long mem_attrs_new; + extern unsigned long mem_attrs_new_modified; + extern unsigned long mem_attrs_shared; + extern unsigned long mem_attrs_shared_modified; + extern unsigned long mem_attrs_shared_copy; + fprintf (stderr, "%lu mem_attrs created (%lu for new, %lu for " + "modification)\n", + mem_attrs_new + mem_attrs_new_modified, + mem_attrs_new, mem_attrs_new_modified); + fprintf (stderr, "%lu mem_attrs shared (%lu for new, %lu for " + "modification, %lu by rtx copying)\n", + mem_attrs_shared + mem_attrs_shared_modified + + mem_attrs_shared_copy, + mem_attrs_shared, mem_attrs_shared_modified, + mem_attrs_shared_copy); + fprintf (stderr, "%lu mem_attrs dropped\n", mem_attrs_dropped); + } + if (warningcount || errorcount || werrorcount) print_ignored_options ();