OSDN Git Service

[codeview,pdb] Try really hard to conserve memory when reading.
authorZachary Turner <zturner@google.com>
Fri, 27 May 2016 01:54:44 +0000 (01:54 +0000)
committerZachary Turner <zturner@google.com>
Fri, 27 May 2016 01:54:44 +0000 (01:54 +0000)
commit0212bc82e0d87b354ba0cf8f76d726b011a5f1cb
tree383af96051c69325c3beebba309026be29168a7b
parentc93d4ea0e39bdb92f0ca0dbeac50213e1236e8ef
[codeview,pdb] Try really hard to conserve memory when reading.

PDBs can be extremely large.  We're already mapping the entire
PDB into the process's address space, but to make matters worse
the blocks of the PDB are not arranged contiguously.  So, when
we have something like an array or a string embedded into the
stream, we have to make a copy.  Since it's convenient to use
traditional data structures to iterate and manipulate these
records, we need the memory to be contiguous.

As a result of this, we were using roughly twice as much memory
as the file size of the PDB, because every stream was copied
out and re-stitched together contiguously.

This patch addresses this by improving the MappedBlockStream
to allocate from a BumpPtrAllocator only when a read requires
a discontiguous read.  Furthermore, it introduces some data
structures backed by a stream which can iterate over both
fixed and variable length records of a PDB.  Since everything
is backed by a stream and not a buffer, we can read almost
everything from the PDB with zero copies.

Differential Revision: http://reviews.llvm.org/D20654
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270951 91177308-0d34-0410-b5e6-96231b3b80d8
26 files changed:
include/llvm/DebugInfo/CodeView/ByteStream.h
include/llvm/DebugInfo/CodeView/StreamArray.h [new file with mode: 0644]
include/llvm/DebugInfo/CodeView/StreamInterface.h
include/llvm/DebugInfo/CodeView/StreamReader.h
include/llvm/DebugInfo/CodeView/StreamRef.h [new file with mode: 0644]
include/llvm/DebugInfo/PDB/Raw/DbiStream.h
include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
include/llvm/DebugInfo/PDB/Raw/ModInfo.h
include/llvm/DebugInfo/PDB/Raw/ModStream.h
include/llvm/DebugInfo/PDB/Raw/NameHashTable.h
include/llvm/DebugInfo/PDB/Raw/PublicsStream.h
include/llvm/DebugInfo/PDB/Raw/TpiStream.h
lib/DebugInfo/CodeView/ByteStream.cpp
lib/DebugInfo/CodeView/StreamReader.cpp
lib/DebugInfo/PDB/CMakeLists.txt
lib/DebugInfo/PDB/Raw/DbiStream.cpp
lib/DebugInfo/PDB/Raw/InfoStream.cpp
lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
lib/DebugInfo/PDB/Raw/ModInfo.cpp
lib/DebugInfo/PDB/Raw/ModStream.cpp
lib/DebugInfo/PDB/Raw/NameHashTable.cpp
lib/DebugInfo/PDB/Raw/NameMap.cpp
lib/DebugInfo/PDB/Raw/PublicsStream.cpp
lib/DebugInfo/PDB/Raw/SymbolStream.cpp
lib/DebugInfo/PDB/Raw/TpiStream.cpp
tools/llvm-pdbdump/llvm-pdbdump.cpp