From 786275e7195761228374d7c0f5ff02403c7e1ef8 Mon Sep 17 00:00:00 2001 From: jimblandy Date: Sat, 17 Jul 2010 15:14:30 +0000 Subject: Breakpad Linux/Mac symbol dumper: Share duplicate strings that arise in DWARF data. This patch avoids allocating many copies of identical strings appearing in debugging information. Without this patch, running dump_syms on Mozilla's libxul.so (with 173MiB of debugging information) has a peak resident set of around 450MiB. With this patch, the peak is around 365MiB. a=jimblandy, r=mark git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@626 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/dwarf_cfi_to_module.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/common/dwarf_cfi_to_module.h') diff --git a/src/common/dwarf_cfi_to_module.h b/src/common/dwarf_cfi_to_module.h index dc11ec53..d29a796c 100644 --- a/src/common/dwarf_cfi_to_module.h +++ b/src/common/dwarf_cfi_to_module.h @@ -40,7 +40,9 @@ #define COMMON_LINUX_DWARF_CFI_TO_MODULE_H #include +#include +#include #include #include @@ -51,6 +53,7 @@ namespace google_breakpad { using dwarf2reader::CallFrameInfo; using google_breakpad::Module; +using std::set; using std::string; using std::vector; @@ -124,7 +127,8 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { DwarfCFIToModule(Module *module, const vector ®ister_names, Reporter *reporter) : module_(module), register_names_(register_names), reporter_(reporter), - entry_(NULL), return_address_(-1) { } + entry_(NULL), return_address_(-1), cfa_name_(".cfa"), ra_name_(".ra") { + } virtual ~DwarfCFIToModule() { delete entry_; } virtual bool Entry(size_t offset, uint64 address, uint64 length, @@ -168,6 +172,23 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { // The return address column for that entry. unsigned return_address_; + + // The names of the return address and canonical frame address. Putting + // these here instead of using string literals allows us to share their + // texts in reference-counted std::string implementations (all the + // popular ones). Many, many rules cite these strings. + string cfa_name_, ra_name_; + + // A set of strings used by this CFI. Before storing a string in one of + // our data structures, insert it into this set, and then use the string + // from the set. + // + // Because std::string uses reference counting internally, simply using + // strings from this set, even if passed by value, assigned, or held + // directly in structures and containers (map, for example), + // causes those strings to share a single instance of each distinct piece + // of text. + set common_strings_; }; } // namespace google_breakpad -- cgit v1.2.1