This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, RFC] New memory usage statistics infrastructure

On 05/15/2015 08:38 AM, Martin LiÅka wrote:

Following patch attempts to rewrite memory reports for GCC's internal
so that it uses a new template type. The type shares parts which are
currently duplicated,
adds support for special 'counters' and introduces new support for

Transformation of the current code is a bit tricky as we internally used
hash-table as main
data structure which takes care of location-related allocations. As I
want to add support even
for hash tables (and all derived types), header files inclusion and
forward declaration is utilized.

Feel free to comment the patch, as well as missing features one may want
to track by location sensitive
memory allocation.

Attachment contains sample output taken from tramp3d-v4.cpp.



 From 7a9048ef36bddf17209acadc1dcab9fc48a7fd63 Mon Sep 17 00:00:00 2001
From: mliska<>
Date: Tue, 5 May 2015 11:34:16 +0200
Subject: [PATCH] New memory allocation statistics infrastructure.


2015-05-05  Martin Liska<>

	* Add additional dependencies related to memory report
	* alloc-pool.c (allocate_pool_descriptor): Use new ctor.
	* bitmap.c (struct bitmap_descriptor_d): Remove.
	(struct loc): Likewise.
	(struct bitmap_desc_hasher): Likewise.
	(bitmap_desc_hasher::hash): Likewise.
	(bitmap_desc_hasher::equal): Likewise.
	(get_bitmap_descriptor): Likewise.
	(bitmap_register): User new memory descriptor API.
	(register_overhead): Likewise.
	(bitmap_find_bit): Register nsearches and search_iter statistics.
	(struct bitmap_output_info): Remove.
	(print_statistics): Likewise.
	(dump_bitmap_statistics): Use new memory descriptor.
	* bitmap.h (struct bitmap_usage): New class.
	* genmatch.c: Extend header file inclusion.
	* genpreds.c: Likewise.
	* ggc-common.c (struct ggc_usage): New class.
	(struct ggc_loc_desc_hasher): Remove.
	(ggc_loc_desc_hasher::hash): Likewise.
	(ggc_loc_desc_hasher::equal): Likewise.
	(struct ggc_ptr_hash_entry): Likewise.
	(struct ptr_hash_hasher): Likewise.
	(ptr_hash_hasher::hash): Likewise.
	(ptr_hash_hasher::equal): Likewise.
	(make_loc_descriptor): Likewise.
	(ggc_prune_ptr): Likewise.
	(dump_ggc_loc_statistics): Use new memory descriptor.
	(ggc_record_overhead): Likewise.
	(ggc_free_overhead): Likewise.
	(final_cmp_statistic): Remove.
	(cmp_statistic): Likewise.
	(ggc_add_statistics): Liekwise.
	(ggc_prune_overhead_list): Likewise.
	* hash-map-traits.h: New file.
	* hash-map.h (struct default_hashmap_traits): Move the traits to a
	separate header file.
	* hash-set.h: Pass memory statistics info to ctor.
	* hash-table.c (void dump_hash_table_loc_statistics): New function.
	* hash-table.h (hash_table::hash_table): Add new ctor arguments.
	(hash_table::~hash_table): Register memory release operation.
	(hash_table::alloc_entries): Handle memory allocation operation.
	(hash_table::expand): Likewise.
	* inchash.c (iterative_hash_hashval_t): Move implementation to header
	(iterative_hash_host_wide_int): Likewise.
	* inchash.h (class hash): Likewise.
	* mem-stats-traits.h: New file.
	* mem-stats.h: New file.
	(mem_location): Add new class.
	(mem_usage): Likewise.
	(mem_alloc_description): Likewise.
	* sese.c: Add new header file inclusision.
	* toplev.c (dump_memory_report): Add report for hash_table, hash_map
	and hash_set.
	* tree-sra.c: Add new header file inclusision.
	* vec.c (struct vec_descriptor): Remove.
	(hash_descriptor): Likewise.
	(struct vec_usage): Likewise.
	(struct ptr_hash_entry): Likewise.
	(hash_ptr): Likewise.
	(eq_ptr): Likewise.
	(vec_prefix::register_overhead): Use new memory descriptor API.
	(vec_prefix::release_overhead): Likewise.
	(add_statistics): Remove.
	(dump_vec_loc_statistics): Use new memory descriptor API.
	* vec.h (struct vec_prefix): Likewise.
	(va_heap::reserve): Likewise.
	(va_heap::release): Likewise.
Please check for overly-long lines. I spotted several, but didn't keep them handy as I was working through the patch. ISTM that using the script from contrib/ might help identify the overly long lines.

Overall it looks good -- I like the consistency in reporting. I think if there's things missing, we ought to be able to add them incrementally.

My recommendation would be to take care of the line wrapping issues, run it through the usual bootstrap and testing cycles and commit assuming nothing is amiss.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]