[llvm] [MemProf] Switch to DenseMap for performance (NFC) (PR #81035)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 12:45:02 PST 2024


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

Some profiling showed that the accesses to this map during bitcode
reading was incurring over 10% of the time in a large thin link. There
is no need for it to be std::map, and I measured around 8.5% time
reduction in the same thin link from switching to DenseMap.


>From c6a58060aba3f4ccf740b99ba7e25a0e6034162c Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Wed, 7 Feb 2024 12:09:29 -0800
Subject: [PATCH] [MemProf] Switch to DenseMap for performance (NFC)

Some profiling showed that the accesses to this map during bitcode
reading was incurring over 10% of the time in a large thin link. There
is no need for it to be std::map, and I measured around 8.5% time
reduction in the same thin link from switching to DenseMap.
---
 llvm/include/llvm/IR/ModuleSummaryIndex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 395c9e332eb8f3..d5ff15063671d8 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1377,7 +1377,7 @@ class ModuleSummaryIndex {
 
   // Temporary map while building StackIds list. Clear when index is completely
   // built via releaseTemporaryMemory.
-  std::map<uint64_t, unsigned> StackIdToIndex;
+  DenseMap<uint64_t, unsigned> StackIdToIndex;
 
   // YAML I/O support.
   friend yaml::MappingTraits<ModuleSummaryIndex>;



More information about the llvm-commits mailing list