[llvm] r311375 - [PDB] Serialize records into a stack-allocated buffer.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 13:17:19 PDT 2017


Author: zturner
Date: Mon Aug 21 13:17:19 2017
New Revision: 311375

URL: http://llvm.org/viewvc/llvm-project?rev=311375&view=rev
Log:
[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

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
    llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h?rev=311375&r1=311374&r2=311375&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h Mon Aug 21 13:17:19 2017
@@ -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;

Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp?rev=311375&r1=311374&r2=311375&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp Mon Aug 21 13:17:19 2017
@@ -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) {




More information about the llvm-commits mailing list