From be1e3d3eab0af2a140463757a1ba3977167551af Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 4 Mar 2020 16:34:49 -0700 Subject: Introduce objfile::intern This introduces a string cache on the per-BFD object, replacing the macro and filename caches. Both of these caches just store strings, so this consolidation by itself saves a little memory (about the size of a bcache per objfile). Then this patch switches some allocations on the objfile obstack to use this bcache instead. This saves more space; and turns out to be a bit faster as well. Here are the before and after "maint time" + "maint space" results of "file ./gdb": Command execution time: 4.664021 (cpu), 4.728518 (wall) Space used: 39190528 (+29212672 for this command) Command execution time: 4.216209 (cpu), 4.107023 (wall) Space used: 36667392 (+26689536 for this command) The main interface to the string cache is a new pair of overloaded methods, objfile::intern. gdb/ChangeLog 2020-03-04 Tom Tromey * symmisc.c (print_symbol_bcache_statistics) (print_objfile_statistics): Update. * symfile.c (allocate_symtab): Use intern. * psymtab.c (partial_symtab::partial_symtab): Use intern. * objfiles.h (struct objfile_per_bfd_storage) : Remove. : New member. (struct objfile) : New methods. * elfread.c (elf_symtab_read): Use intern. * dwarf2/read.c (fixup_go_packaging): Intern package name. (dwarf2_compute_name, dwarf2_physname) (create_dwo_unit_in_dwp_v1, create_dwo_unit_in_dwp_v2): Intern names. (guess_partial_die_structure_name): Update. (partial_die_info::fixup): Intern name. (dwarf2_canonicalize_name): Change parameter to objfile. Intern name. (dwarf2_name): Intern name. Update. * buildsym.c (buildsym_compunit::get_macro_table): Use string_cache. --- gdb/symmisc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'gdb/symmisc.c') diff --git a/gdb/symmisc.c b/gdb/symmisc.c index a6a7e72..1d7c381 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -71,9 +71,7 @@ print_symbol_bcache_statistics (void) objfile_name (objfile)); objfile->partial_symtabs->psymbol_cache.print_statistics ("partial symbol cache"); - objfile->per_bfd->macro_cache.print_statistics - ("preprocessor macro cache"); - objfile->per_bfd->filename_cache.print_statistics ("file name cache"); + objfile->per_bfd->string_cache.print_statistics ("string cache"); } } @@ -135,10 +133,8 @@ print_objfile_statistics (void) printf_filtered (_(" Total memory used for psymbol cache: %d\n"), objfile->partial_symtabs->psymbol_cache.memory_used ()); - printf_filtered (_(" Total memory used for macro cache: %d\n"), - objfile->per_bfd->macro_cache.memory_used ()); - printf_filtered (_(" Total memory used for file name cache: %d\n"), - objfile->per_bfd->filename_cache.memory_used ()); + printf_filtered (_(" Total memory used for string cache: %d\n"), + objfile->per_bfd->string_cache.memory_used ()); } } -- cgit v1.1