[llvm] [memprof] Improve deserialization performance in V3 (PR #94787)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 17:17:41 PDT 2024


================
@@ -494,17 +494,43 @@ static uint64_t writeMemProfFrames(
 static llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId>
 writeMemProfFrameArray(
     ProfOStream &OS,
-    llvm::MapVector<memprof::FrameId, memprof::Frame> &MemProfFrameData) {
+    llvm::MapVector<memprof::FrameId, memprof::Frame> &MemProfFrameData,
+    llvm::DenseMap<memprof::FrameId, memprof::FrameStat> &FrameHistogram) {
   // Mappings from FrameIds to array indexes.
   llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId> MemProfFrameIndexes;
 
-  // Sort the FrameIDs for stability.
+  // Compute the order in which we serialize Frames.  The order does not matter
+  // in terms of correctness, but we still compute it for two reasons:
+  //
+  // - Stability of the output: If we sort by FrameIds at least, then the output
----------------
kazutakahirata wrote:

Fixed in the latest iteration.  It's a lot better to mention the FrameId comparison as the final tie breaker all the away at the end.

https://github.com/llvm/llvm-project/pull/94787


More information about the llvm-commits mailing list