[Lldb-commits] [lldb] r145086 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFCompileUnit.cpp DWARFCompileUnit.h DWARFDebugInfoEntry.cpp
Greg Clayton
gclayton at apple.com
Tue Nov 22 13:35:28 PST 2011
Author: gclayton
Date: Tue Nov 22 15:35:27 2011
New Revision: 145086
URL: http://llvm.org/viewvc/llvm-project?rev=145086&view=rev
Log:
Shrink-to-fit our std::vector<DWARFDebugInfoEntry> collections and save 20%
to 30% of memory. The size doubling was killing us and we ended up with up to
just under 50% of empty capacity. Cleaning this up saves us a ton of memory.
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=145086&r1=145085&r2=145086&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Tue Nov 22 15:35:27 2011
@@ -271,7 +271,17 @@
}
fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path);
}
+
+ // Since std::vector objects will double their size, we really need to
+ // make a new array with the perfect size so we don't end up wasting
+ // space. So here we copy and swap to make sure we don't have any extra
+ // memory taken up.
+ if (m_die_array.size () < m_die_array.capacity())
+ {
+ DWARFDebugInfoEntry::collection exact_size_die_array (m_die_array.begin(), m_die_array.end());
+ exact_size_die_array.swap (m_die_array);
+ }
LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO));
if (log)
{
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=145086&r1=145085&r2=145086&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Tue Nov 22 15:35:27 2011
@@ -74,13 +74,11 @@
}
void
- AddDIE(DWARFDebugInfoEntry& die)
+ AddDIE (DWARFDebugInfoEntry& die)
{
// The average bytes per DIE entry has been seen to be
- // around 14-20 so lets pre-reserve the needed memory for
- // our DIE entries accordingly. Search forward for "Compute
- // average bytes per DIE" to see #if'ed out code that does
- // that determination.
+ // around 14-20 so lets pre-reserve half of that since
+ // we are now stripping the NULL tags.
// Only reserve the memory if we are adding children of
// the main compile unit DIE. The compile unit DIE is always
@@ -88,7 +86,7 @@
// the first compile unit child DIE and should reserve
// the memory.
if (m_die_array.empty())
- m_die_array.reserve(GetDebugInfoSize() / 14);
+ m_die_array.reserve(GetDebugInfoSize() / 24);
m_die_array.push_back(die);
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=145086&r1=145085&r2=145086&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Tue Nov 22 15:35:27 2011
@@ -1926,8 +1926,8 @@
{
DWARFDebugInfoEntry::const_iterator pos;
DWARFDebugInfoEntry::const_iterator end = die_collection.end();
- puts("offset parent sibling child");
- puts("-------- -------- -------- --------");
+ strm.PutCString("\noffset parent sibling child\n");
+ strm.PutCString("-------- -------- -------- --------\n");
for (pos = die_collection.begin(); pos != end; ++pos)
{
const DWARFDebugInfoEntry& die_ref = *pos;
More information about the lldb-commits
mailing list