Show hash table stats when -fmem-report

Dimitrios Apostolou jimis@gmx.net
Mon May 21 14:00:00 GMT 2012


Hello list,

I ported a patch from last year's GSOC to current trunk, removing 
deprecated hash tables and adding some new ones. I also backed out a 
change that reduced collisions by decreasing load factor because it had 
created controversy, so this patch should be easily applicable.

CC'd whoever is relevant with subsystems or had commented on this last 
year. Some notes:

  * Is it OK that I included <assert.h> in libiberty's hashtab.c?
  * Many hash tables are created with htab_create_ggc(), for example 
referenced_vars and default_defs in tree-ssa.c. I collect statistics in 
delete_tree_ssa() but maybe some are not deallocated in there but 
automatically garbage collected?
  * Obviously hash table sizes are inflated where two entries might 
reference the same element (for example in symtab_hash) but I don't handle 
this.
  * Maybe the best overall solution would be to add a string parameter to 
htab_create*() and store statistics in an internal hash table according to 
this string. Statistics would then be printed for all hash tables by 
iterating this internal table. Since it would cause a significant 
slowdown, -fmem-report would be better as a compile-time option than a 
run-time one. This is probably an overkill so I think I'll skip it.


Thanks,
Dimitris



2012-05-21 Dimitrios Apostolou <jimis@gmx.net>

 	Print various statistics about hash tables when called with
 	-fmem-report. If the tables are created once use
 	htab_dump_statistics(), if they are created/destroyed multiple
 	times then introduce global variables to track statistics.

 	* cgraph.c, cgraph.h:
 	(cgraph_dump_stats): New function to dump stats about hash tables.
 	* gcc/symtab.c, cgraph.h:
 	(symtab_dump_stats): New function to dump stats about hash tables.
 	* cgraph.c: (call_site_hash_{num,expands,searches,collisions}):
 	New globals to keep statistics about call_site_hash hash tables.
 	(cgraph_remove_node_callees,cgraph_remove_node): if (mem_report)
 	then keep statistics about hash tables.
 	* cselib.c, cselib.h (cselib_dump_stats): New function to dump
 	stats about cselib_hash_table.
 	* cselib.c (cselib_htab_{num,expands,searches,collisions}): New
 	globals to keep hash table statistics.
 	(cselib_finish): if (mem_report) keep hash table statistics.
 	* dwarf2out.c (dwarf2out_finish): Call htab_dump_statistics() if
 	-fmem_report.
 	* emit-rtl.c, emit-rtl.h (mem_attrs_dump_stats): New function to
 	dump statistics about mem_attrs_htab hash table.
 	* tree.h, tree-ssa.c (tree_ssa_dump_stats): New function to print
 	statistics about all referenced_vars and default_defs hash tables.
 	* tree-ssa.c (default_defs_{num,expands,searches,collisions})
 	(referenced_vars_{num,expands,searches,collisions}): new globals
 	to keep statistics about hash tables.
 	(delete_tree_ssa): Keep statistics for hash tables by
 	increasing the new global variables.
 	* tree.c (dump_tree_statistics): Call tree_ssa_dump_stats().
 	(print_type_hash_statistics): Used the new htab_dump_statistics()
 	function.
 	* var-tracking.c (vars_htab_{num,expands,searches,collisions})
 	(dropval_htab_{num,expands,searches,collisions})
 	(cv_htab_{num,expands,searches,collisions}): new globals to keep
 	hash table statistics.
 	(shared_hash_destroy, vt_finalize): Keep statistics by
 	increasing values of new global variables if -fmem-report.
 	* var-tracking.c, rtl.h (vt_dump_stats): New function to dump
 	stats about vars->htab, dropped_variables and value_chains hash
 	tables.
 	* toplev.c: Included cselib.h for cselib_dump_stats().
 	(dump_memory_report): Call all the above functions to provide
 	better statistics.

 	* hashtab.c, hashtab.h: Added "expands" variable to htab_t for
 	tracking total times the hash table was expanded.
 	* hashtab.c, hashtab.h (htab_dump_statistics, htab_collisions_num)
 	(htab_searches_num, htab_expands_num): New functions for 
statistics.
 	* hashtab.c: Included assert.h for checks in htab_dump_statistics.
 	* cgraph.h, varpool.c (varpool_dump_stats): New function to dump
 	stats about varpool_hash hash table.

 	* libcpp/symtab.c, symtab.h: Added "expands" variable to
 	hash_table type for tracking total times the hash table was
 	expanded.
 	* symtab.c (ht_dump_statistics): Beautified stats output.



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ht-sample.log
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120521/cd0b0343/attachment.log>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ht.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120521/cd0b0343/attachment.ksh>


More information about the Gcc-patches mailing list