[llvm] [ThinLTO] Use DenseMap for OidGuidMap (PR #107725)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 7 16:04:34 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/107725
We use OidGuidMap only to map an old GUID to a new one. We don't use
std::set's strengths like iterators staying valid or the ability to
traverse in a sorted order.
As a data point, during the ThinLTO indexing step of a large
application of ours, we create 440,000 mappings. Our memory profiler
reports reduction of 127MB in the peak memory usage (out of 4.991GB),
which is bigger than expected savings most likely due to some noise.
The savings should be about 8MB at the max load factor of DenseMap.
>From 0b165ec154a7314801227c520cc88e1cac93e5d1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 7 Sep 2024 13:24:34 -0700
Subject: [PATCH] [ThinLTO] Use DenseMap for OidGuidMap
We use OidGuidMap only to map an old GUID to a new one. We don't use
std::set's strengths like iterators staying valid or the ability to
traverse in a sorted order.
As a data point, during the ThinLTO indexing step of a large
application of ours, we create 440,000 mappings. Our memory profiler
reports reduction of 127MB in the peak memory usage (out of 4.991GB),
which is bigger than expected savings most likely due to some noise.
The savings should be about 8MB at the max load factor of 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 af3734cc2c54b5..dae208d0b132e4 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1343,7 +1343,7 @@ class ModuleSummaryIndex {
/// Mapping from original ID to GUID. If original ID can map to multiple
/// GUIDs, it will be mapped to 0.
- std::map<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
+ DenseMap<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
/// Indicates that summary-based GlobalValue GC has run, and values with
/// GVFlags::Live==false are really dead. Otherwise, all values must be
More information about the llvm-commits
mailing list