From patchwork Tue Mar 27 19:37:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 149015 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 D2F03B6EEC for ; Wed, 28 Mar 2012 06:38:08 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1333481889; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=OUjjYbl TO2X546q8tNJBkyPfOsE=; b=nIQGqTliLNAt7jRN9JkYyJyMQgARO0RUSS4KS1e ka0MW4Y8NepHmmwKD8pO6uH2F3M8WpgG9vLkIVyOPFPiqRtWST+srd0I4ofbKME3 2yzkN7bIAPl1bkIhJqFrqxwpgIz4bP4lrxDD9CQJo4xotZGr4Fp0zqNLPmhPnLZ2 q6r0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=IaSS7EtnaY8HWedKBHwWPETivJ4uAoV4Ixp8fltPb404qfz0q71Wz1X5oD2g7I puoXWki9bu1PUBqJyALPV8Rn9RPrSYiaD/EnXSooK9bs3tUCPBskI7Smx127kd9k dfZVP+Jn75p+tumED4vszpKvDIzXKfRHGHmrRtV6C3A8M=; Received: (qmail 29231 invoked by alias); 27 Mar 2012 19:38:06 -0000 Received: (qmail 29202 invoked by uid 22791); 27 Mar 2012 19:38:05 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-wg0-f73.google.com (HELO mail-wg0-f73.google.com) (74.125.82.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Mar 2012 19:37:51 +0000 Received: by wgbdq12 with SMTP id dq12so14552wgb.2 for ; Tue, 27 Mar 2012 12:37:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=GCK1c5V0F2KRNtAbuI1fpK8yHwuyeRGYSrZt+KGp2l0=; b=OJ9y+FVp9SHKCxvb72Ca7pN9YW22UYaOp0ky3lFAfDSbJm8UwLyvab9BrVj2IBFt/r 9LkqaxXl+8PFCjbyUFNJ3H7C4lL8J3pdF7C1Fb20KnBhTjRzhnvFgtzxIkms7QiQ/x3L S2K6qqNXus2JL1k73F+QN5k+Fpc+lm2N1EZbzdO3HKItMHV5hUSq5i2H8TABI+74vkZ3 dS42PJ5pofDIej32Vw7KJshM1H1mXgXEQNKN0syVSZ+EvHN9le4fmaVNZD5KPzjWepLo 79/gI0VXB8zeNtwePRn3iYixjRkK/+SFBmjUKiPt93Qo1cRBQbK8LEOkQpAgTzKjgP3B wlAg== Received: by 10.14.37.16 with SMTP id x16mr6369892eea.1.1332877070123; Tue, 27 Mar 2012 12:37:50 -0700 (PDT) Received: by 10.14.37.16 with SMTP id x16mr6369880eea.1.1332877069997; Tue, 27 Mar 2012 12:37:49 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id z52si486931eeb.1.2012.03.27.12.37.49 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 27 Mar 2012 12:37:49 -0700 (PDT) Received: from tobiano.tor.corp.google.com (tobiano.tor.corp.google.com [172.29.41.6]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id A859D5C0050; Tue, 27 Mar 2012 12:37:49 -0700 (PDT) Received: by tobiano.tor.corp.google.com (Postfix, from userid 54752) id B7802AE1F2; Tue, 27 Mar 2012 15:37:48 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Add more PPH timers and stats. (issue5937045) Message-Id: <20120327193748.B7802AE1F2@tobiano.tor.corp.google.com> Date: Tue, 27 Mar 2012 15:37:48 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) X-Gm-Message-State: ALoCoQne09YFYWaFuj8cp97n7fMtDOaXT1Qk+4D/cGYAYKI2oGDOYJYHfMIDyeJpuWkN/rl9ohov2gGDXO0Eh+3dVBFG6HDfvVw76MnDRy+PcROS/hMU3Wk+cOz7+haLGdLtmoOPAnZZPArD/KzKQoJxTdbq5o03BDeqEJFrren8IVr5kQZzIAE= 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 Add more PPH timers and stats. We are spending too much time inside the reading of template bodies. This patch adds more timers that pinpoint the problem to be the hashing of specialization tables. We spend roughly 50% of PPH reading inside the hashing code. 2012-03-27 Diego Novillo cp/ChangeLog.pph * pph-core.c (pph_dump_stats): Print pph_stats.num_spec_entry_elems. * pph.h (struct pph_stats_s): Add field num_spec_entry_elems. * pt.c (pph_out_spec_entry_htab): Update pph_stats.num_spec_entry_elems. (pph_in_bodies_spec_entry_htab): Likewise. Add timer TV_PPH_SPECIALIZATION_HASH around hashing operations. ChangeLog.pph * timevar.def (TV_PPH_SPECIALIZATION_HASH): New timer. (TV_PPH_OUT_MERGE_KEYS, TV_PPH_OUT_MERGE_BODIES, TV_PPH_IN_MERGE_KEYS, TV_PPH_IN_MERGE_BODIES): Remove. (TV_PPH_OUT_BL_K): New. Update previous users of TV_PPH_OUT_MERGE_KEYS. (TV_PPH_OUT_BL_B): New. Update previous users of TV_PPH_OUT_MERGE_BODIES. (TV_PPH_OUT_TMPL_K): New. Update previous users of TV_PPH_OUT_MERGE_KEYS. (TV_PPH_OUT_TMPL_B): New. Update previous users of TV_PPH_OUT_MERGE_BODIES. (TV_PPH_IN_BL_K): New. Update previous users of TV_PPH_OUT_MERGE_KEYS. (TV_PPH_IN_BL_B): New. Update previous users of TV_PPH_OUT_MERGE_BODIES. (TV_PPH_IN_TMPL_K): New. Update previous users of TV_PPH_OUT_MERGE_KEYS. (TV_PPH_IN_TMPL_B): New. Update previous users of TV_PPH_OUT_MERGE_BODIES. --- This patch is available for review at http://codereview.appspot.com/5937045 diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index f16675c..da91524 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -1601,6 +1601,10 @@ pph_dump_stats (FILE *f) PERCENT (pph_stats.cache_hits, pph_stats.cache_lookups)); fprintf (f, "\n"); + fprintf (f, "Number of elements in all spec_entry tables: %lu", + pph_stats.num_spec_entry_elems); + + fprintf (f, "\n"); timevar_print (f); } diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index d50581e..546a591 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -3121,7 +3121,7 @@ pph_in_global_binding_keys (pph_stream *stream) cp_binding_level *bl, *other_bl; bool existed_p; - timevar_start (TV_PPH_IN_MERGE_KEYS); + timevar_start (TV_PPH_IN_BL_K); bl = scope_chain->bindings; other_bl = pph_in_binding_level_start (stream, bl, &existed_p); @@ -3138,7 +3138,7 @@ pph_in_global_binding_keys (pph_stream *stream) bound to scope_chain->bindings. */ pph_in_merge_key_binding_level (stream, &bl); - timevar_stop (TV_PPH_IN_MERGE_KEYS); + timevar_stop (TV_PPH_IN_BL_K); } @@ -3151,14 +3151,14 @@ pph_in_global_binding_bodies (pph_stream *stream) { cp_binding_level *bl = scope_chain->bindings; - timevar_start (TV_PPH_IN_MERGE_BODIES); + timevar_start (TV_PPH_IN_BL_B); /* Once all the symbols and types at every binding level have been merged to the corresponding binding levels in the current compilation, read all the bodies. */ pph_in_merge_body_binding_level (stream, bl); - timevar_stop (TV_PPH_IN_MERGE_BODIES); + timevar_stop (TV_PPH_IN_BL_B); } diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c index 018a5f0..7b4cf01 100644 --- a/gcc/cp/pph-out.c +++ b/gcc/cp/pph-out.c @@ -2610,7 +2610,7 @@ pph_out_global_binding_keys (pph_stream *stream) { cp_binding_level *bl; - timevar_start (TV_PPH_OUT_MERGE_KEYS); + timevar_start (TV_PPH_OUT_BL_K); /* We only need to write out the scope_chain->bindings, everything else should be NULL or be some temporary disposable state. @@ -2643,7 +2643,7 @@ pph_out_global_binding_keys (pph_stream *stream) reading multiple PPH images. */ pph_out_merge_key_binding_level (stream, bl); - timevar_stop (TV_PPH_OUT_MERGE_KEYS); + timevar_stop (TV_PPH_OUT_BL_K); } @@ -2654,12 +2654,12 @@ pph_out_global_binding_bodies (pph_stream *stream) { cp_binding_level *bl = scope_chain->bindings; - timevar_start (TV_PPH_OUT_MERGE_BODIES); + timevar_start (TV_PPH_OUT_BL_B); /* Now emit all the bodies. */ pph_out_merge_body_binding_level (stream, bl); - timevar_stop (TV_PPH_OUT_MERGE_BODIES); + timevar_stop (TV_PPH_OUT_BL_B); } diff --git a/gcc/cp/pph.h b/gcc/cp/pph.h index 74860be..b28b3cc 100644 --- a/gcc/cp/pph.h +++ b/gcc/cp/pph.h @@ -164,6 +164,9 @@ typedef struct pph_stats_s { /* Total number of replay actions in the replay table. */ unsigned long num_replay_actions; + + /* Total number of entries in a spec_entry template table. */ + unsigned long num_spec_entry_elems; } pph_stats_t; extern pph_stats_t pph_stats; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2cd3835..6a4c634 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -20803,6 +20803,7 @@ pph_out_spec_entry_htab (pph_stream *stream, htab_t *table, unsigned count = htab_elements (*table); /*FIXME pph: This write may be unstable. */ pph_out_uint (stream, count); + pph_stats.num_spec_entry_elems += count; if (flag_pph_debug >= 2) fprintf (pph_logfile, "PPH: writing %d spec_entries\n", count ); htab_traverse_noresize (*table, func, stream); @@ -20885,6 +20886,9 @@ static void pph_in_bodies_spec_entry_htab (pph_stream *stream, htab_t *table) { unsigned count = pph_in_uint (stream); + + pph_stats.num_spec_entry_elems += count; + if (flag_pph_debug >= 2) fprintf (pph_logfile, "PPH: loading bodies %d spec_entries\n", count ); for (; count > 0; --count) @@ -20895,8 +20899,10 @@ pph_in_bodies_spec_entry_htab (pph_stream *stream, htab_t *table) se->tmpl = pph_in_tree (stream); se->args = pph_in_tree (stream); se->spec = pph_in_tree (stream); + timevar_start (TV_PPH_SPECIALIZATION_HASH); hash = hash_specialization (se); slot = (spec_entry **)htab_find_slot_with_hash (*table, se, hash, INSERT); + timevar_stop (TV_PPH_SPECIALIZATION_HASH); *slot = se; } } @@ -20907,12 +20913,14 @@ pph_in_bodies_spec_entry_htab (pph_stream *stream, htab_t *table) void pph_out_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED) { - timevar_start (TV_PPH_OUT_MERGE_KEYS); + timevar_start (TV_PPH_OUT_TMPL_K); + pph_out_spec_entry_htab (stream, &decl_specializations, pph_out_key_spec_entry_slot); pph_out_spec_entry_htab (stream, &type_specializations, pph_out_key_spec_entry_slot); - timevar_stop (TV_PPH_OUT_MERGE_KEYS); + + timevar_stop (TV_PPH_OUT_TMPL_K); } @@ -20921,7 +20929,7 @@ pph_out_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED) void pph_out_merge_body_template_state (pph_stream *stream) { - timevar_start (TV_PPH_OUT_MERGE_BODIES); + timevar_start (TV_PPH_OUT_TMPL_B); pph_out_spec_entry_htab (stream, &decl_specializations, pph_out_body_spec_entry_slot); @@ -20935,7 +20943,7 @@ pph_out_merge_body_template_state (pph_stream *stream) pph_dump_pending_templates_list (stderr); } - timevar_stop (TV_PPH_OUT_MERGE_BODIES); + timevar_stop (TV_PPH_OUT_TMPL_B); } @@ -20950,7 +20958,7 @@ static strptrmap_t *type_spec_tbl = NULL; void pph_in_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED) { - timevar_start (TV_PPH_IN_MERGE_KEYS); + timevar_start (TV_PPH_IN_TMPL_K); if (!decl_spec_tbl) decl_spec_tbl = strptrmap_create (); @@ -20961,7 +20969,7 @@ pph_in_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED) pph_in_keys_spec_entry_htab (stream, pph_in_search_key_spec, type_spec_tbl); - timevar_stop (TV_PPH_IN_MERGE_KEYS); + timevar_stop (TV_PPH_IN_TMPL_K); } @@ -20970,7 +20978,7 @@ pph_in_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED) void pph_in_merge_body_template_state (pph_stream *stream) { - timevar_start (TV_PPH_IN_MERGE_BODIES); + timevar_start (TV_PPH_IN_TMPL_B); pph_in_bodies_spec_entry_htab (stream, &decl_specializations); pph_in_bodies_spec_entry_htab (stream, &type_specializations); @@ -20982,7 +20990,7 @@ pph_in_merge_body_template_state (pph_stream *stream) pph_dump_pending_templates_list (stderr); } - timevar_stop (TV_PPH_IN_MERGE_BODIES); + timevar_stop (TV_PPH_IN_TMPL_B); } diff --git a/gcc/timevar.def b/gcc/timevar.def index 1b50892..b1dd3db 100644 --- a/gcc/timevar.def +++ b/gcc/timevar.def @@ -63,20 +63,25 @@ DEFTIMEVAR (TV_PCH_CPP_RESTORE , "PCH preprocessor state restore") /* Time spent saving/restoring PPH state. */ DEFTIMEVAR (TV_PPH , "PPH (global)") DEFTIMEVAR (TV_PPH_VALIDATE_IDENTIFIERS, "PPH validate identifiers") +DEFTIMEVAR (TV_PPH_SPECIALIZATION_HASH, "PPH specialization hash") DEFTIMEVAR (TV_PPH_OUT , "PPH out (main)") DEFTIMEVAR (TV_PPH_OUT_LINE_TABLE , "PPH out (line table)") DEFTIMEVAR (TV_PPH_OUT_IDENTIFIERS , "PPH out (identifiers)") -DEFTIMEVAR (TV_PPH_OUT_MERGE_KEYS , "PPH out (merge keys)") -DEFTIMEVAR (TV_PPH_OUT_MERGE_BODIES , "PPH out (merge bodies)") +DEFTIMEVAR (TV_PPH_OUT_BL_K , "PPH out (BL [k])") +DEFTIMEVAR (TV_PPH_OUT_BL_B , "PPH out (BL [b])") +DEFTIMEVAR (TV_PPH_OUT_TMPL_K , "PPH out (TMPL [k])") +DEFTIMEVAR (TV_PPH_OUT_TMPL_B , "PPH out (TMPL [b])") DEFTIMEVAR (TV_PPH_OUT_MISC , "PPH out (misc state)") DEFTIMEVAR (TV_PPH_OUT_REPLAY , "PPH out (replay table)") DEFTIMEVAR (TV_PPH_IN , "PPH in (main)") DEFTIMEVAR (TV_PPH_IN_LINE_TABLE , "PPH in (line table)") DEFTIMEVAR (TV_PPH_IN_IDENTIFIERS , "PPH in (identifiers)") -DEFTIMEVAR (TV_PPH_IN_MERGE_KEYS , "PPH in (merge keys)") -DEFTIMEVAR (TV_PPH_IN_MERGE_BODIES , "PPH in (merge bodies)") +DEFTIMEVAR (TV_PPH_IN_BL_K , "PPH in (BL [k])") +DEFTIMEVAR (TV_PPH_IN_BL_B , "PPH in (BL [b])") +DEFTIMEVAR (TV_PPH_IN_TMPL_K , "PPH in (TMPL [k])") +DEFTIMEVAR (TV_PPH_IN_TMPL_B , "PPH in (TMPL [b])") DEFTIMEVAR (TV_PPH_IN_MISC , "PPH in (misc state)") DEFTIMEVAR (TV_PPH_IN_REPLAY , "PPH in (replay table)")