This initial set of timers measures time spent in the major phases of PPH processing. We may want to add/remove timers as we measure performance.
2012-03-26 Diego Novillo <dnovi...@google.com> cp/ChangeLog.pph * pph-core.c (pph_include_handler): Use timer TV_PPH. (pph_init): Likewise. (pph_finish): Likewise. * pph-in.c (pph_in_line_table_and_includes): Use timer TV_PPH_RESTORE_LINE_TABLE. (pph_in_replay): Use timer TV_PPH_RESTORE_REPLAY. (pph_in_identifiers): Use timer TV_PPH_RESTORE_IDENTIFIERS. (pph_in_global_binding_keys): Use timer TV_PPH_RESTORE_MERGE_KEYS. (pph_in_global_binding_bodies): Use timer TV_PPH_RESTORE_MERGE_BODIES. (pph_read_file_1): Use timer TV_PPH_RESTORE_MISC and timer TV_PPH_VALIDATE_IDENTIFIERS. (pph_read_file): Use timer TV_PPH_RESTORE. * pph-out.c (pph_writer_init): Use timer TV_PPH_SAVE. (pph_out_line_table_and_includes): Use timer TV_PPH_SAVE_LINE_TABLE. (pph_out_replay): Use timer TV_PPH_SAVE_REPLAY. (pph_out_identifiers): Use timer TV_PPH_SAVE_IDENTIFIERS. (pph_out_global_binding_keys): Use timer TV_PPH_SAVE_MERGE_KEYS. (pph_out_global_binding_bodies): Use timer TV_PPH_SAVE_MERGE_BODIES. (pph_write_file): Use timer TV_PPH_SAVE_MISC. (pph_writer_finish): Use timer TV_PPH_SAVE. * pt.c (pph_in_bodies_spec_entry_htab): Use timer TV_PPH_RESTORE_MERGE_BODIES. (pph_out_merge_key_template_state): Use timer TV_PPH_SAVE_MERGE_KEYS. (pph_out_merge_body_template_state): Use timer TV_PPH_SAVE_MERGE_BODIES. (pph_in_merge_key_template_state): Use timer TV_PPH_RESTORE_MERGE_KEYS. (pph_in_merge_body_template_state): Use timer TV_PPH_RESTORE_MERGE_BODIES. ChangeLog.pph * timevar.def (TV_PPH): New timer. (TV_PPH_VALIDATE_IDENTIFIERS): New timer. (TV_PPH_SAVE): New timer. (TV_PPH_SAVE_LINE_TABLE): New timer. (TV_PPH_SAVE_IDENTIFIERS): New timer. (TV_PPH_SAVE_MERGE_KEYS): New timer. (TV_PPH_SAVE_MERGE_BODIES): New timer. (TV_PPH_SAVE_MISC): New timer. (TV_PPH_SAVE_REPLAY): New timer. (TV_PPH_RESTORE): New timer. (TV_PPH_RESTORE_LINE_TABLE): New timer. (TV_PPH_RESTORE_IDENTIFIERS): New timer. (TV_PPH_RESTORE_MERGE_KEYS): New timer. (TV_PPH_RESTORE_MERGE_BODIES): New timer. (TV_PPH_RESTORE_MISC): New timer. (TV_PPH_RESTORE_REPLAY): New timer. --- gcc/ChangeLog.pph | 19 +++++++++++++++++++ gcc/cp/ChangeLog.pph | 33 +++++++++++++++++++++++++++++++++ gcc/cp/pph-core.c | 12 ++++++++++++ gcc/cp/pph-in.c | 29 ++++++++++++++++++++++++++++- gcc/cp/pph-out.c | 31 ++++++++++++++++++++++++++++++- gcc/cp/pt.c | 14 ++++++++++++++ gcc/timevar.def | 20 ++++++++++++++++++++ 7 files changed, 156 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog.pph b/gcc/ChangeLog.pph index 2bf6c9a..5d8a45c 100644 --- a/gcc/ChangeLog.pph +++ b/gcc/ChangeLog.pph @@ -1,3 +1,22 @@ +2012-03-26 Diego Novillo <dnovi...@google.com> + + * timevar.def (TV_PPH): New timer. + (TV_PPH_VALIDATE_IDENTIFIERS): New timer. + (TV_PPH_SAVE): New timer. + (TV_PPH_SAVE_LINE_TABLE): New timer. + (TV_PPH_SAVE_IDENTIFIERS): New timer. + (TV_PPH_SAVE_MERGE_KEYS): New timer. + (TV_PPH_SAVE_MERGE_BODIES): New timer. + (TV_PPH_SAVE_MISC): New timer. + (TV_PPH_SAVE_REPLAY): New timer. + (TV_PPH_RESTORE): New timer. + (TV_PPH_RESTORE_LINE_TABLE): New timer. + (TV_PPH_RESTORE_IDENTIFIERS): New timer. + (TV_PPH_RESTORE_MERGE_KEYS): New timer. + (TV_PPH_RESTORE_MERGE_BODIES): New timer. + (TV_PPH_RESTORE_MISC): New timer. + (TV_PPH_RESTORE_REPLAY): New timer. + 2012-03-04 Diego Novillo <dnovi...@google.com> * tree.c (type_hash_traverse): Declare. diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index f5b8281..3f6f5bb 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,3 +1,36 @@ +2012-03-26 Diego Novillo <dnovi...@google.com> + + * pph-core.c (pph_include_handler): Use timer TV_PPH. + (pph_init): Likewise. + (pph_finish): Likewise. + * pph-in.c (pph_in_line_table_and_includes): Use timer + TV_PPH_RESTORE_LINE_TABLE. + (pph_in_replay): Use timer TV_PPH_RESTORE_REPLAY. + (pph_in_identifiers): Use timer TV_PPH_RESTORE_IDENTIFIERS. + (pph_in_global_binding_keys): Use timer + TV_PPH_RESTORE_MERGE_KEYS. + (pph_in_global_binding_bodies): Use timer + TV_PPH_RESTORE_MERGE_BODIES. + (pph_read_file_1): Use timer TV_PPH_RESTORE_MISC and timer + TV_PPH_VALIDATE_IDENTIFIERS. + (pph_read_file): Use timer TV_PPH_RESTORE. + * pph-out.c (pph_writer_init): Use timer TV_PPH_SAVE. + (pph_out_line_table_and_includes): Use timer + TV_PPH_SAVE_LINE_TABLE. + (pph_out_replay): Use timer TV_PPH_SAVE_REPLAY. + (pph_out_identifiers): Use timer TV_PPH_SAVE_IDENTIFIERS. + (pph_out_global_binding_keys): Use timer TV_PPH_SAVE_MERGE_KEYS. + (pph_out_global_binding_bodies): Use timer TV_PPH_SAVE_MERGE_BODIES. + (pph_write_file): Use timer TV_PPH_SAVE_MISC. + (pph_writer_finish): Use timer TV_PPH_SAVE. + * pt.c (pph_in_bodies_spec_entry_htab): Use timer + TV_PPH_RESTORE_MERGE_BODIES. + (pph_out_merge_key_template_state): Use timer TV_PPH_SAVE_MERGE_KEYS. + (pph_out_merge_body_template_state): Use timer TV_PPH_SAVE_MERGE_BODIES. + (pph_in_merge_key_template_state): Use timer TV_PPH_RESTORE_MERGE_KEYS. + (pph_in_merge_body_template_state): Use timer + TV_PPH_RESTORE_MERGE_BODIES. + 2012-03-25 Diego Novillo <dnovi...@google.com> * pph-out.c (pph_out_global_binding_keys): Fix check for empty diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index feaee29..2a16f86 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -883,6 +883,8 @@ pph_include_handler (cpp_reader *reader, const char *pph_file; bool read_text_file_p; + timevar_start (TV_PPH); + if (flag_pph_tracer >= 1) { fprintf (pph_logfile, "PPH: #%s", dname); @@ -930,6 +932,8 @@ pph_include_handler (cpp_reader *reader, "using original header %s", pph_file, name); } + timevar_stop (TV_PPH); + return read_text_file_p; } @@ -1477,6 +1481,8 @@ pph_init (void) cpp_callbacks *cb; cpp_lookaside *table; + timevar_start (TV_PPH); + if (flag_pph_logfile) { pph_logfile = fopen (flag_pph_logfile, "w"); @@ -1510,6 +1516,8 @@ pph_init (void) pph_writer_init (); pph_reader_init (); + + timevar_stop (TV_PPH); } @@ -1565,6 +1573,8 @@ bool pph_check_main_guarded (void) void pph_finish (void) { + timevar_start (TV_PPH); + /* If we found errors during compilation, disable PPH generation. */ if (errorcount || sorrycount) pph_disable_output (); @@ -1578,6 +1588,8 @@ pph_finish (void) if (flag_pph_logfile) fclose (pph_logfile); + + timevar_stop (TV_PPH); } #include "gt-cp-pph-core.h" diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index b032315..445e4b6 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -353,6 +353,8 @@ pph_in_line_table_and_includes (pph_stream *stream) enum pph_linetable_marker next_lt_marker; int top_includer_ix; + timevar_start (TV_PPH_RESTORE_LINE_TABLE); + used_before = LINEMAPS_ORDINARY_USED (line_table); first = true; @@ -460,6 +462,8 @@ pph_in_line_table_and_includes (pph_stream *stream) linemap_add (line_table, LC_LEAVE, 0, NULL, 0); gcc_assert (line_table->depth == old_depth); + timevar_stop (TV_PPH_RESTORE_LINE_TABLE); + return MAP_START_LOCATION (LINEMAPS_ORDINARY_MAP_AT (line_table, used_before)); } @@ -2883,6 +2887,8 @@ pph_in_replay (pph_stream *stream) { unsigned i, num; + timevar_start (TV_PPH_RESTORE_REPLAY); + /* Register all the symbols in STREAM in the same order of the original compilation for this header file. */ num = pph_in_uint (stream); @@ -2974,6 +2980,8 @@ pph_in_replay (pph_stream *stream) else gcc_unreachable (); } + + timevar_stop (TV_PPH_RESTORE_REPLAY); } @@ -3028,6 +3036,8 @@ pph_in_identifiers (pph_stream *stream, cpp_idents_used *identifiers) unsigned int max_ident_len, max_value_len, num_entries; unsigned int ident_len, before_len, after_len; + timevar_start (TV_PPH_RESTORE_IDENTIFIERS); + max_ident_len = pph_in_uint (stream); identifiers->max_ident_len = max_ident_len; max_value_len = pph_in_uint (stream); @@ -3089,6 +3099,8 @@ pph_in_identifiers (pph_stream *stream, cpp_idents_used *identifiers) identifiers->entries[j].after_str = NULL; } } + + timevar_stop (TV_PPH_RESTORE_IDENTIFIERS); } @@ -3102,6 +3114,8 @@ pph_in_global_binding_keys (pph_stream *stream) cp_binding_level *bl, *other_bl; bool existed_p; + timevar_start (TV_PPH_RESTORE_MERGE_KEYS); + bl = scope_chain->bindings; other_bl = pph_in_binding_level_start (stream, bl, &existed_p); @@ -3116,6 +3130,8 @@ pph_in_global_binding_keys (pph_stream *stream) same slot IX that the writer used, the trees read now will be bound to scope_chain->bindings. */ pph_in_merge_key_binding_level (stream, &bl); + + timevar_stop (TV_PPH_RESTORE_MERGE_KEYS); } @@ -3128,10 +3144,14 @@ pph_in_global_binding_bodies (pph_stream *stream) { cp_binding_level *bl = scope_chain->bindings; + timevar_start (TV_PPH_RESTORE_MERGE_BODIES); + /* 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_RESTORE_MERGE_BODIES); } @@ -3193,6 +3213,7 @@ pph_read_file_1 (pph_stream *stream) pph_in_identifiers (stream, &idents_used); /* FIXME pph: This validation is weak. */ + timevar_start (TV_PPH_VALIDATE_IDENTIFIERS); verified = cpp_lt_verify_1 (parse_in, &idents_used, &bad_use, &cur_def, true); if (!verified) report_validation_error (stream->name, bad_use->ident_str, cur_def, @@ -3204,6 +3225,7 @@ pph_read_file_1 (pph_stream *stream) adding locations which wouldn't be there in the non-pph compile; thus working towards an identical line_table in pph and non-pph. */ cpp_lt_replay (parse_in, &idents_used, &cpp_token_replay_loc); + timevar_stop (TV_PPH_VALIDATE_IDENTIFIERS); /* Read the namespace scope bindings and template state from STREAM. */ pph_in_global_binding_keys (stream); @@ -3213,13 +3235,14 @@ pph_read_file_1 (pph_stream *stream) /* Read and merge the other global state collected during parsing of the original header. */ + timevar_start (TV_PPH_RESTORE_MISC); pph_union_into_chain (&keyed_classes, pph_in_tree (stream)); pph_union_into_tree_vec (&unemitted_tinfo_decls, pph_in_tree_vec (stream)); file_static_aggregates = pph_in_tree (stream); static_aggregates = chainon (file_static_aggregates, static_aggregates); pph_in_decl2_hidden_state (stream); - pph_in_canonical_template_parms (stream); + timevar_stop (TV_PPH_RESTORE_MISC); /* Read and process the symbol and type re-play table. This re-executes all the actions done to present symbols and types to @@ -3267,6 +3290,8 @@ pph_add_include (pph_stream *parent, pph_stream *include) pph_stream * pph_read_file (const char *filename, pph_stream *parent) { + timevar_start (TV_PPH_RESTORE); + pph_stream *stream = pph_stream_open (filename, "rb"); if (stream) { @@ -3283,6 +3308,8 @@ pph_read_file (const char *filename, pph_stream *parent) pph_add_include (parent, stream); } + timevar_stop (TV_PPH_RESTORE); + return stream; } diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c index 1efac6b..147416c 100644 --- a/gcc/cp/pph-out.c +++ b/gcc/cp/pph-out.c @@ -85,10 +85,14 @@ pph_init_write (pph_stream *stream) void pph_writer_init (void) { + timevar_start (TV_PPH_SAVE); + gcc_assert (pph_out_stream == NULL); pph_out_stream = pph_stream_open (pph_out_file, "wb"); if (pph_out_stream == NULL) fatal_error ("Cannot open PPH file %s for writing: %m", pph_out_file); + + timevar_stop (TV_PPH_SAVE); } @@ -319,6 +323,8 @@ pph_out_line_table_and_includes (pph_stream *stream) { int ix; + timevar_start (TV_PPH_SAVE_LINE_TABLE); + /* Any #include should have been fully parsed and exited at this point. */ gcc_assert (line_table->depth == 0); @@ -423,6 +429,8 @@ pph_out_line_table_and_includes (pph_stream *stream) pph_out_source_location (stream, line_table->highest_line); pph_out_uint (stream, line_table->max_column_hint); + + timevar_stop (TV_PPH_SAVE_LINE_TABLE); } @@ -2503,6 +2511,8 @@ pph_out_replay (pph_stream *stream) pph_replay_entry *entry; unsigned i; + timevar_start (TV_PPH_SAVE_REPLAY); + pph_out_uint (stream, VEC_length (pph_replay_entry, stream->replay.v)); FOR_EACH_VEC_ELT (pph_replay_entry, stream->replay.v, i, entry) { @@ -2525,6 +2535,8 @@ pph_out_replay (pph_stream *stream) pph_out_bool (stream, cgraph_get_node (entry->to_replay) != NULL); } } + + timevar_stop (TV_PPH_SAVE_REPLAY); } @@ -2535,6 +2547,8 @@ pph_out_identifiers (pph_stream *stream, cpp_idents_used *identifiers) { unsigned int num_entries, active_entries, id; + timevar_start (TV_PPH_SAVE_IDENTIFIERS); + num_entries = identifiers->num_entries; pph_out_uint (stream, identifiers->max_ident_len); pph_out_uint (stream, identifiers->max_value_len); @@ -2575,6 +2589,8 @@ pph_out_identifiers (pph_stream *stream, cpp_idents_used *identifiers) pph_out_string_with_length (stream, entry->after_str, entry->after_len); } + + timevar_stop (TV_PPH_SAVE_IDENTIFIERS); } @@ -2585,6 +2601,8 @@ pph_out_global_binding_keys (pph_stream *stream) { cp_binding_level *bl; + timevar_start (TV_PPH_SAVE_MERGE_KEYS); + /* We only need to write out the scope_chain->bindings, everything else should be NULL or be some temporary disposable state. old_namespace should be global_namespace and all entries listed @@ -2615,6 +2633,8 @@ pph_out_global_binding_keys (pph_stream *stream) /* Emit all the merge keys for objects that need to be merged when reading multiple PPH images. */ pph_out_merge_key_binding_level (stream, bl); + + timevar_stop (TV_PPH_SAVE_MERGE_KEYS); } @@ -2625,8 +2645,12 @@ pph_out_global_binding_bodies (pph_stream *stream) { cp_binding_level *bl = scope_chain->bindings; + timevar_start (TV_PPH_SAVE_MERGE_BODIES); + /* Now emit all the bodies. */ pph_out_merge_body_binding_level (stream, bl); + + timevar_stop (TV_PPH_SAVE_MERGE_BODIES); } @@ -2656,12 +2680,13 @@ pph_write_file (pph_stream *stream) /* Emit other global state kept by the parser. FIXME pph, these globals should be fields in struct cp_parser. */ + timevar_start (TV_PPH_SAVE_MISC); pph_out_tree (stream, keyed_classes); pph_out_tree_vec (stream, unemitted_tinfo_decls); pph_out_tree (stream, static_aggregates); pph_out_decl2_hidden_state (stream); - pph_out_canonical_template_parms (stream); + timevar_stop (TV_PPH_SAVE_MISC); /* Emit the symbol table. The symbol table must be emitted at the end because all the symbols read from children PPH images are not @@ -2773,11 +2798,15 @@ pph_writer_finish (void) if (pph_out_stream == NULL) return; + timevar_start (TV_PPH_SAVE); + if (!pph_check_main_missing_guard || pph_check_main_guarded ()) pph_write_file (pph_out_stream); pph_stream_close (pph_out_stream); pph_out_stream = NULL; + + timevar_stop (TV_PPH_SAVE); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8d95e7a..3f00fbe 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -20907,10 +20907,12 @@ 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_SAVE_MERGE_KEYS); 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_SAVE_MERGE_KEYS); } @@ -20919,6 +20921,8 @@ 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_SAVE_MERGE_BODIES); + pph_out_spec_entry_htab (stream, &decl_specializations, pph_out_body_spec_entry_slot); pph_out_spec_entry_htab (stream, &type_specializations, @@ -20930,6 +20934,8 @@ pph_out_merge_body_template_state (pph_stream *stream) pph_dump_spec_entry_htab (pph_logfile, "type", &type_specializations); pph_dump_pending_templates_list (stderr); } + + timevar_stop (TV_PPH_SAVE_MERGE_BODIES); } @@ -20944,6 +20950,8 @@ static strptrmap_t *type_spec_tbl = NULL; void pph_in_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED) { + timevar_start (TV_PPH_RESTORE_MERGE_KEYS); + if (!decl_spec_tbl) decl_spec_tbl = strptrmap_create (); if (!type_spec_tbl) @@ -20952,6 +20960,8 @@ pph_in_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED) decl_spec_tbl); pph_in_keys_spec_entry_htab (stream, pph_in_search_key_spec, type_spec_tbl); + + timevar_stop (TV_PPH_RESTORE_MERGE_KEYS); } @@ -20960,6 +20970,8 @@ 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_RESTORE_MERGE_BODIES); + pph_in_bodies_spec_entry_htab (stream, &decl_specializations); pph_in_bodies_spec_entry_htab (stream, &type_specializations); pph_in_pending_templates_list (stream); @@ -20969,6 +20981,8 @@ pph_in_merge_body_template_state (pph_stream *stream) pph_dump_spec_entry_htab (pph_logfile, "decl", &decl_specializations); pph_dump_pending_templates_list (stderr); } + + timevar_stop (TV_PPH_RESTORE_MERGE_BODIES); } diff --git a/gcc/timevar.def b/gcc/timevar.def index 1f5ea2a..42dfa1a 100644 --- a/gcc/timevar.def +++ b/gcc/timevar.def @@ -60,6 +60,26 @@ DEFTIMEVAR (TV_PCH_PTR_SORT , "PCH pointer sort") DEFTIMEVAR (TV_PCH_RESTORE , "PCH main state restore") 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_SAVE , "PPH save (main)") +DEFTIMEVAR (TV_PPH_SAVE_LINE_TABLE , "PPH save (line table)") +DEFTIMEVAR (TV_PPH_SAVE_IDENTIFIERS , "PPH save (identifiers)") +DEFTIMEVAR (TV_PPH_SAVE_MERGE_KEYS , "PPH save (merge keys)") +DEFTIMEVAR (TV_PPH_SAVE_MERGE_BODIES , "PPH save (merge bodies)") +DEFTIMEVAR (TV_PPH_SAVE_MISC , "PPH save (misc state)") +DEFTIMEVAR (TV_PPH_SAVE_REPLAY , "PPH save (replay table)") + +DEFTIMEVAR (TV_PPH_RESTORE , "PPH restore (main)") +DEFTIMEVAR (TV_PPH_RESTORE_LINE_TABLE , "PPH restore (line table)") +DEFTIMEVAR (TV_PPH_RESTORE_IDENTIFIERS , "PPH restore (identifiers)") +DEFTIMEVAR (TV_PPH_RESTORE_MERGE_KEYS , "PPH restore (merge keys)") +DEFTIMEVAR (TV_PPH_RESTORE_MERGE_BODIES, "PPH restore (merge bodies)") +DEFTIMEVAR (TV_PPH_RESTORE_MISC , "PPH restore (misc state)") +DEFTIMEVAR (TV_PPH_RESTORE_REPLAY , "PPH restore (replay table)") + DEFTIMEVAR (TV_CGRAPH , "callgraph construction") DEFTIMEVAR (TV_CGRAPHOPT , "callgraph optimization") DEFTIMEVAR (TV_VARPOOL , "varpool construction") -- 1.7.7.3 -- This patch is available for review at http://codereview.appspot.com/5902062