aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfWriter.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-05-29 12:18:24 -0700
committerGitHub <noreply@github.com>2024-05-29 12:18:24 -0700
commit99b9ab45cd67648a7b6c2ba02041072fe4de346b (patch)
tree93628587eb4f1bcb4573db79e2efc036cb123ab8 /llvm/lib/ProfileData/InstrProfWriter.cpp
parentb3bbb2de6fab74b714f38c0bf0822e1634b0d158 (diff)
downloadllvm-99b9ab45cd67648a7b6c2ba02041072fe4de346b.zip
llvm-99b9ab45cd67648a7b6c2ba02041072fe4de346b.tar.gz
llvm-99b9ab45cd67648a7b6c2ba02041072fe4de346b.tar.bz2
[memprof] Reorder MemProf sections in profile (#93640)
This patch teaches the V3 format to serialize Frames, call stacks, and IndexedMemProfRecords, in that order. I'm planning to use linear IDs for Frames. That is, Frames will be numbered 0, 1, 2, and so on in the order we serialize them. In turn, we will seialize the call stacks in terms of those linear IDs. Likewise, I'm planning to use linear IDs for call stacks and then serialize IndexedMemProfRecords in terms of those linear IDs for call stacks. With the new order, we can successively free data structures as we serialize them. That is, once we serialize Frames, we can free the Frames' data proper and just retain mappings from FrameIds to linear IDs. A similar story applies to call stacks.
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index e732882..7e0c9a1 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -619,48 +619,48 @@ static Error writeMemProfV2(ProfOStream &OS,
// Write out MemProf Version3 as follows:
// uint64_t Version
-// uint64_t RecordTableOffset = RecordTableGenerator.Emit
-// uint64_t FramePayloadOffset = Offset for the frame payload
// uint64_t FrameTableOffset = FrameTableGenerator.Emit
// uint64_t CallStackPayloadOffset = Offset for the call stack payload
// uint64_t CallStackTableOffset = CallStackTableGenerator.Emit
+// uint64_t RecordPayloadOffset = Offset for the record payload
+// uint64_t RecordTableOffset = RecordTableGenerator.Emit
// uint64_t Num schema entries
// uint64_t Schema entry 0
// uint64_t Schema entry 1
// ....
// uint64_t Schema entry N - 1
-// OnDiskChainedHashTable MemProfRecordData
// OnDiskChainedHashTable MemProfFrameData
// OnDiskChainedHashTable MemProfCallStackData
+// OnDiskChainedHashTable MemProfRecordData
static Error writeMemProfV3(ProfOStream &OS,
memprof::IndexedMemProfData &MemProfData,
bool MemProfFullSchema) {
OS.write(memprof::Version3);
uint64_t HeaderUpdatePos = OS.tell();
- OS.write(0ULL); // Reserve space for the memprof record table offset.
- OS.write(0ULL); // Reserve space for the memprof frame payload offset.
OS.write(0ULL); // Reserve space for the memprof frame table offset.
OS.write(0ULL); // Reserve space for the memprof call stack payload offset.
OS.write(0ULL); // Reserve space for the memprof call stack table offset.
+ OS.write(0ULL); // Reserve space for the memprof record payload offset.
+ OS.write(0ULL); // Reserve space for the memprof record table offset.
auto Schema = memprof::getHotColdSchema();
if (MemProfFullSchema)
Schema = memprof::getFullSchema();
writeMemProfSchema(OS, Schema);
- uint64_t RecordTableOffset = writeMemProfRecords(OS, MemProfData.RecordData,
- &Schema, memprof::Version3);
-
- uint64_t FramePayloadOffset = OS.tell();
uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.FrameData);
uint64_t CallStackPayloadOffset = OS.tell();
uint64_t CallStackTableOffset =
writeMemProfCallStacks(OS, MemProfData.CallStackData);
+ uint64_t RecordPayloadOffset = OS.tell();
+ uint64_t RecordTableOffset = writeMemProfRecords(OS, MemProfData.RecordData,
+ &Schema, memprof::Version3);
+
uint64_t Header[] = {
- RecordTableOffset, FramePayloadOffset, FrameTableOffset,
- CallStackPayloadOffset, CallStackTableOffset,
+ FrameTableOffset, CallStackPayloadOffset, CallStackTableOffset,
+ RecordPayloadOffset, RecordTableOffset,
};
OS.patch({{HeaderUpdatePos, Header, std::size(Header)}});