[llvm] 1a52994 - [MemProf][NFC] Free large data structures after last use (#75120)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 11:38:25 PST 2023


Author: Teresa Johnson
Date: 2023-12-15T11:38:21-08:00
New Revision: 1a5299491a455356b4aae8ee47ceceebd00c2103

URL: https://github.com/llvm/llvm-project/commit/1a5299491a455356b4aae8ee47ceceebd00c2103
DIFF: https://github.com/llvm/llvm-project/commit/1a5299491a455356b4aae8ee47ceceebd00c2103.diff

LOG: [MemProf][NFC] Free large data structures after last use (#75120)

The MemProf InstrProfWriter uses a couple of MapVector for building the
lists of records it needs to write. Once its entries are all added to
the associated OnDiskChainedHashTableGenerator, it is no longer used.

Clearing these MapVectors, which grow quite large for large profiles,
saved 4G for a large memory profile.

Added: 
    

Modified: 
    llvm/lib/ProfileData/InstrProfWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 595c9aa1adc105..68b77a1482976a 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -536,6 +536,8 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
       // Insert the key (func hash) and value (memprof record).
       RecordTableGenerator.insert(I.first, I.second);
     }
+    // Release the memory of this MapVector as it is no longer needed.
+    MemProfRecordData.clear();
 
     uint64_t RecordTableOffset =
         RecordTableGenerator.Emit(OS.OS, *RecordWriter);
@@ -549,6 +551,8 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
       // Insert the key (frame id) and value (frame contents).
       FrameTableGenerator.insert(I.first, I.second);
     }
+    // Release the memory of this MapVector as it is no longer needed.
+    MemProfFrameData.clear();
 
     uint64_t FrameTableOffset = FrameTableGenerator.Emit(OS.OS, *FrameWriter);
 


        


More information about the llvm-commits mailing list