forked from OSchip/llvm-project
[PDB] Serialize records into a stack-allocated buffer.
We were using a std::vector<> and resizing to MaxRecordLength, which is ~64KB. We would then do this repeatedly often many times in a tight loop, which was causing measurable performance impact when linking PDBs. Patch by Alex Telishev Differential Revision: https://reviews.llvm.org/D36940 llvm-svn: 311375
This commit is contained in:
parent
fb0994b37e
commit
5641c07d6b
|
@ -28,7 +28,10 @@ namespace codeview {
|
|||
|
||||
class SymbolSerializer : public SymbolVisitorCallbacks {
|
||||
BumpPtrAllocator &Storage;
|
||||
std::vector<uint8_t> RecordBuffer;
|
||||
// Since this is a fixed size buffer, use a stack allocated buffer. This
|
||||
// yields measurable performance increase over the repeated heap allocations
|
||||
// when serializing many independent records via writeOneSymbol.
|
||||
std::array<uint8_t, MaxRecordLength> RecordBuffer;
|
||||
MutableBinaryByteStream Stream;
|
||||
BinaryStreamWriter Writer;
|
||||
SymbolRecordMapping Mapping;
|
||||
|
|
|
@ -21,8 +21,7 @@ using namespace llvm::codeview;
|
|||
|
||||
SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator,
|
||||
CodeViewContainer Container)
|
||||
: Storage(Allocator), RecordBuffer(MaxRecordLength),
|
||||
Stream(RecordBuffer, support::little), Writer(Stream),
|
||||
: Storage(Allocator), Stream(RecordBuffer, support::little), Writer(Stream),
|
||||
Mapping(Writer, Container) {}
|
||||
|
||||
Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) {
|
||||
|
|
Loading…
Reference in New Issue