[llvm] [memprof][NFC] Free symbolizer memory eagerly (PR #75119)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 16:29:28 PST 2023


https://github.com/teresajohnson created https://github.com/llvm/llvm-project/pull/75119

Free the symbolizer as soon as we are done with it, to reduce peak
memory in the reader. This reduces about 9G from the peak for one large
profile.


>From 686b2c947bf31f7fa0adf088817905e62dc42247 Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Sat, 9 Dec 2023 16:10:11 -0800
Subject: [PATCH] [memprof][NFC] Free symbolizer memory eagerly

Free the symbolizer as soon as we are done with it, to reduce peak
memory in the reader. This reduces about 9G from the peak for one large
profile.
---
 llvm/lib/ProfileData/RawMemProfReader.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/ProfileData/RawMemProfReader.cpp b/llvm/lib/ProfileData/RawMemProfReader.cpp
index af2db8d61179a..21d98260d4d2d 100644
--- a/llvm/lib/ProfileData/RawMemProfReader.cpp
+++ b/llvm/lib/ProfileData/RawMemProfReader.cpp
@@ -536,6 +536,9 @@ Error RawMemProfReader::symbolizeAndFilterStackFrames() {
       EntriesToErase.push_back(Entry.getFirst());
   }
 
+  // Free symbolizer memory now that we are done with it.
+  Symbolizer.reset();
+
   // Drop the entries where the callstack is empty.
   for (const uint64_t Id : EntriesToErase) {
     StackMap.erase(Id);



More information about the llvm-commits mailing list