[llvm] [memprof] Create a call stack table (PR #86575)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 13:27:50 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/86575
We are in the process of reducing the size of the indexed memprof file
by creating a hash table of call stacks so that IndexedAllocationInfo
can refer to a call stack with the hash of the call stack. The idea
is analogus to IdToFrame, a hash table to map a FrameId to its
corresponding Frame.
This patch prepares for that future by keeping call stacks in a hash
table so that we can drop CallStack from IndexedAllocationInfo.
We will eventually serialize the hash table into an indexed profile
file just as we serialize MemProfFrameData, a hash table of Frames
indexed by FrameId.
This patch does not add a use of the hash table yet.
>From f90660ceb69a673185e8f8381ed9f33b61678d0f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 25 Mar 2024 12:41:38 -0700
Subject: [PATCH] [memprof] Create a call stack table
We are in the process of reducing the size of the indexed memprof file
by creating a hash table of call stacks so that IndexedAllocationInfo
can refer to a call stack with the hash of the call stack. The idea
is analogus to IdToFrame, a hash table to map a FrameId to its
corresponding Frame.
This patch prepares for that future by keeping call stacks in a hash
table so that we can drop CallStack from IndexedAllocationInfo.
We will eventually serialize the hash table into an indexed profile
file just as we serialize MemProfFrameData, a hash table of Frames
indexed by FrameId.
This patch does not add a use of the hash table yet.
---
llvm/include/llvm/ProfileData/RawMemProfReader.h | 2 ++
llvm/lib/ProfileData/RawMemProfReader.cpp | 1 +
2 files changed, 3 insertions(+)
diff --git a/llvm/include/llvm/ProfileData/RawMemProfReader.h b/llvm/include/llvm/ProfileData/RawMemProfReader.h
index 6aa5caec65f791..8b8c5c9f242369 100644
--- a/llvm/include/llvm/ProfileData/RawMemProfReader.h
+++ b/llvm/include/llvm/ProfileData/RawMemProfReader.h
@@ -97,6 +97,8 @@ class MemProfReader {
}
// A mapping from FrameId (a hash of the contents) to the frame.
llvm::DenseMap<FrameId, Frame> IdToFrame;
+ // A mapping from CallStackId (a hash of the contents) to the call stack.
+ llvm::DenseMap<CallStackId, SmallVector<FrameId>> CallStackIdToCallStack;
// A mapping from function GUID, hash of the canonical function symbol to the
// memprof profile data for that function, i.e allocation and callsite info.
llvm::MapVector<GlobalValue::GUID, IndexedMemProfRecord> FunctionProfileData;
diff --git a/llvm/lib/ProfileData/RawMemProfReader.cpp b/llvm/lib/ProfileData/RawMemProfReader.cpp
index 5dc1ff8978154c..6e294849170b2f 100644
--- a/llvm/lib/ProfileData/RawMemProfReader.cpp
+++ b/llvm/lib/ProfileData/RawMemProfReader.cpp
@@ -447,6 +447,7 @@ Error RawMemProfReader::mapRawProfileToRecords() {
}
CallStackId CSId = hashCallStack(Callstack);
+ CallStackIdToCallStack.insert({CSId, Callstack});
// We attach the memprof record to each function bottom-up including the
// first non-inline frame.
More information about the llvm-commits
mailing list