summaryrefslogtreecommitdiff
path: root/compiler/utils/dedupe_set-inl.h
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2022-03-17 12:55:27 +0000
committer Vladimir Marko <vmarko@google.com> 2022-04-04 16:40:55 +0000
commitf67e8c35ee11b0bd81a2d6f6e267b9081db7d758 (patch)
tree4b5331d57e63554d7a7a84020bb971dcf50c6507 /compiler/utils/dedupe_set-inl.h
parent65258db896c8270873f362d95204336d7d1e333d (diff)
Preallocate `CodeInfoTableDeduper::dedupe_set_`.
Preallocate large buffer except for multi-image compilation which requires multiple dedupe sets, so we let them grow as needed without wasting too much memory. We do not expect to use multi-image compilation on user devices. Also remove the hash from the dedupe set entry. With the large pre-allocated buffer, we have very few hash conflicts and comparing the hash just slows down finding identical entries. If we exceed the pre-allocated buffer, this shall trade some performance for lower memory use. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: Ibbb98b6d3ebbc35ffa75165baad54f4df7c62ad9
Diffstat (limited to 'compiler/utils/dedupe_set-inl.h')
-rw-r--r--compiler/utils/dedupe_set-inl.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler/utils/dedupe_set-inl.h b/compiler/utils/dedupe_set-inl.h
index 4e892f2616..d4a9cc829b 100644
--- a/compiler/utils/dedupe_set-inl.h
+++ b/compiler/utils/dedupe_set-inl.h
@@ -81,6 +81,11 @@ class DedupeSet<InKey, StoreKey, Alloc, HashType, HashFunc, kShard>::Shard {
return store_key;
}
+ size_t Size(Thread* self) {
+ MutexLock lock(self, lock_);
+ return keys_.size();
+ }
+
void UpdateStats(Thread* self, Stats* global_stats) REQUIRES(!lock_) {
// HashSet<> doesn't keep entries ordered by hash, so we actually allocate memory
// for bookkeeping while collecting the stats.
@@ -234,6 +239,20 @@ template <typename InKey,
typename HashType,
typename HashFunc,
HashType kShard>
+size_t DedupeSet<InKey, StoreKey, Alloc, HashType, HashFunc, kShard>::Size(Thread* self) const {
+ size_t result = 0u;
+ for (const auto& shard : shards_) {
+ result += shard->Size(self);
+ }
+ return result;
+}
+
+template <typename InKey,
+ typename StoreKey,
+ typename Alloc,
+ typename HashType,
+ typename HashFunc,
+ HashType kShard>
std::string DedupeSet<InKey, StoreKey, Alloc, HashType, HashFunc, kShard>::DumpStats(
Thread* self) const {
Stats stats;