From patchwork Tue Nov 5 10:36:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1189571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512416-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="e9CiSSPX"; dkim-atps=neutral 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 476mLh30ryz9sNT for ; Tue, 5 Nov 2019 21:36:58 +1100 (AEDT) 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=mRkE6AGnyxLIl2KeDztncjFD7+4P98+wPzNRPPBdxh7A/22AGodt5 9Pi8VXjqJA+eMRI0b+BibS2x0mzU3+1kraNGRMQS05kQG9MIUn/wjsdH8Q6vIxt4 KPbot2epMfPVAJayvK3ugoWtRzj+6JG+dm39OIln3uB+NZ6JqlIg54= 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:subject:message-id:mime-version:content-type; s= default; bh=wqpHWDTedSQM/9YEWI7AUwmHXBM=; b=e9CiSSPX8Mj/UCxsU2mq q42TUIzrQSY7HV1AAyNH0AvXg1VixIYtpKOIP2JJtxAerWXVv/ygkZmdIaPoHFox zZcpf7hxkIgHoWhXvsG3iByHnhH0dr2IMY+EtqMJ4zaMjdSb+VIGUl9l8p3yCAA5 32kEUq7OD87aZ2jSo4nEIek= Received: (qmail 115611 invoked by alias); 5 Nov 2019 10:36:49 -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 115603 invoked by uid 89); 5 Nov 2019 10:36:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=7817, UD:allocate, ipapredicatec, gimplify.h X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Nov 2019 10:36:45 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 62BE3282BD5; Tue, 5 Nov 2019 11:36:42 +0100 (CET) Date: Tue, 5 Nov 2019 11:36:42 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, mliska@suse.cz Subject: Add object allocators to symbol and call summaries Message-ID: <20191105103642.y7obi2q65lqykecv@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch adds object allocators to manage IPA summaries. This reduces malloc overhead and fragmentation. I now get peak memory use 7.5GB instead of 10GB for firefox WPA because reduced fragmentation leads to less COWs after forks. Additional bonus is that we now have statistics gathered by mem-reports which makes my life easier, too. (though memory stats are far from ideal - we need to pass location info around bit more). Bootstrapped/regtested x86_64-linux, will commit it shortly. * hsa-brig.c: Include alloc-pool.h * hsa-dump.c: Likewise. * hsa-gen.c: Likewise. * hse-regalloc.c: Likewise. * ipa-hsa.c: Likewise. * ipa-predicate.c: Likewise. * ipa-reference.c: Likewise. * ipa-sra.c: Likewise. * omp-expand.c: Likewise. * omp-general.c: Likewise. * omp-low.c: Likewise. * sumbol-summary.h (function_summary_base): Add allocator. (function_summary::function_summary): Update construction. (fast_function_summary::fast_function_summary): Likewise. (call_summary_base): Add allcator. (call_summary::call_summary): Update construction. (fast_call_summary::fast_call_summary): Likewise. Index: hsa-brig.c =================================================================== --- hsa-brig.c (revision 277796) +++ hsa-brig.c (working copy) @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. #include "cgraph.h" #include "dumpfile.h" #include "print-tree.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "hsa-common.h" #include "gomp-constants.h" Index: hsa-dump.c =================================================================== --- hsa-dump.c (revision 277796) +++ hsa-dump.c (working copy) @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. #include "gimple-pretty-print.h" #include "cgraph.h" #include "print-tree.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "hsa-common.h" Index: hsa-gen.c =================================================================== --- hsa-gen.c (revision 277796) +++ hsa-gen.c (working copy) @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. #include "ssa-iterators.h" #include "cgraph.h" #include "print-tree.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "hsa-common.h" #include "cfghooks.h" Index: hsa-regalloc.c =================================================================== --- hsa-regalloc.c (revision 277796) +++ hsa-regalloc.c (working copy) @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. #include "cgraph.h" #include "print-tree.h" #include "cfghooks.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "hsa-common.h" Index: ipa-hsa.c =================================================================== --- ipa-hsa.c (revision 277796) +++ ipa-hsa.c (working copy) @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. #include "stringpool.h" #include "cgraph.h" #include "print-tree.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "hsa-common.h" Index: ipa-predicate.c =================================================================== --- ipa-predicate.c (revision 277796) +++ ipa-predicate.c (working copy) @@ -25,8 +25,8 @@ along with GCC; see the file COPYING3. #include "tree.h" #include "cgraph.h" #include "tree-vrp.h" -#include "symbol-summary.h" #include "alloc-pool.h" +#include "symbol-summary.h" #include "ipa-prop.h" #include "ipa-fnsummary.h" #include "real.h" Index: ipa-reference.c =================================================================== --- ipa-reference.c (revision 277796) +++ ipa-reference.c (working copy) @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. #include "calls.h" #include "ipa-utils.h" #include "ipa-reference.h" +#include "alloc-pool.h" #include "symbol-summary.h" /* The static variables defined within the compilation unit that are Index: ipa-sra.c =================================================================== --- ipa-sra.c (revision 277796) +++ ipa-sra.c (working copy) @@ -75,6 +75,7 @@ along with GCC; see the file COPYING3. #include "gimple-walk.h" #include "tree-dfa.h" #include "tree-sra.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "params.h" #include "dbgcnt.h" Index: omp-expand.c =================================================================== --- omp-expand.c (revision 277796) +++ omp-expand.c (working copy) @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. #include "omp-general.h" #include "omp-offload.h" #include "tree-cfgcleanup.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "gomp-constants.h" #include "gimple-pretty-print.h" Index: omp-general.c =================================================================== --- omp-general.c (revision 277796) +++ omp-general.c (working copy) @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. #include "attribs.h" #include "gimplify.h" #include "cgraph.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "hsa-common.h" #include "tree-pass.h" Index: omp-low.c =================================================================== --- omp-low.c (revision 277796) +++ omp-low.c (working copy) @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. #include "omp-low.h" #include "omp-grid.h" #include "gimple-low.h" +#include "alloc-pool.h" #include "symbol-summary.h" #include "tree-nested.h" #include "context.h" Index: symbol-summary.h =================================================================== --- symbol-summary.h (revision 277796) +++ symbol-summary.h (working copy) @@ -28,8 +28,10 @@ class function_summary_base { public: /* Default construction takes SYMTAB as an argument. */ - function_summary_base (symbol_table *symtab): m_symtab (symtab), - m_insertion_enabled (true) + function_summary_base (symbol_table *symtab CXX_MEM_STAT_INFO): + m_symtab (symtab), + m_insertion_enabled (true), + allocator ("function summary" PASS_MEM_STAT) {} /* Basic implementation of insert operation. */ @@ -59,7 +61,8 @@ protected: { /* Call gcc_internal_because we do not want to call finalizer for a type T. We call dtor explicitly. */ - return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T () : new T () ; + return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T () + : allocator.allocate () ; } /* Release an item that is stored within map. */ @@ -71,7 +74,7 @@ protected: ggc_free (item); } else - delete item; + allocator.remove (item); } /* Unregister all call-graph hooks. */ @@ -92,6 +95,7 @@ protected: private: /* Return true when the summary uses GGC memory for allocation. */ virtual bool is_ggc () = 0; + object_allocator allocator; }; template @@ -215,9 +219,8 @@ private: template function_summary::function_summary (symbol_table *symtab, bool ggc MEM_STAT_DECL): - function_summary_base (symtab), m_ggc (ggc), m_map (13, ggc, true, - GATHER_STATISTICS - PASS_MEM_STAT) + function_summary_base (symtab PASS_MEM_STAT), m_ggc (ggc), + m_map (13, ggc, true, GATHER_STATISTICS PASS_MEM_STAT) { this->m_symtab_insertion_hook = this->m_symtab->add_cgraph_insertion_hook (function_summary::symtab_insertion, @@ -411,7 +414,7 @@ private: template fast_function_summary::fast_function_summary (symbol_table *symtab MEM_STAT_DECL): - function_summary_base (symtab), m_vector (NULL) + function_summary_base (symtab PASS_MEM_STAT), m_vector (NULL) { vec_alloc (m_vector, 13 PASS_MEM_STAT); this->m_symtab_insertion_hook @@ -531,8 +534,10 @@ class call_summary_base { public: /* Default construction takes SYMTAB as an argument. */ - call_summary_base (symbol_table *symtab): m_symtab (symtab), - m_initialize_when_cloning (false) + call_summary_base (symbol_table *symtab CXX_MEM_STAT_INFO): + m_symtab (symtab), + m_initialize_when_cloning (false), + allocator ("call summary" PASS_MEM_STAT) {} /* Basic implementation of removal operation. */ @@ -547,7 +552,8 @@ protected: { /* Call gcc_internal_because we do not want to call finalizer for a type T. We call dtor explicitly. */ - return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T () : new T () ; + return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T () + : allocator.allocate (); } /* Release an item that is stored within map. */ @@ -559,7 +565,7 @@ protected: ggc_free (item); } else - delete item; + allocator.remove (item); } /* Unregister all call-graph hooks. */ @@ -578,6 +584,7 @@ protected: private: /* Return true when the summary uses GGC memory for allocation. */ virtual bool is_ggc () = 0; + object_allocator allocator; }; template @@ -607,9 +614,8 @@ public: /* Default construction takes SYMTAB as an argument. */ call_summary (symbol_table *symtab, bool ggc = false CXX_MEM_STAT_INFO) - : call_summary_base (symtab), m_ggc (ggc), m_map (13, ggc, true, - GATHER_STATISTICS - PASS_MEM_STAT) + : call_summary_base (symtab PASS_MEM_STAT), m_ggc (ggc), + m_map (13, ggc, true, GATHER_STATISTICS PASS_MEM_STAT) { this->m_symtab_removal_hook = this->m_symtab->add_edge_removal_hook (call_summary::symtab_removal, @@ -775,7 +781,7 @@ class GTY((user)) fast_call_summary (symtab), m_vector (NULL) + : call_summary_base (symtab PASS_MEM_STAT), m_vector (NULL) { vec_alloc (m_vector, 13 PASS_MEM_STAT); this->m_symtab_removal_hook