diff options
author | Abseil Team <absl-team@google.com> | 2021-09-15 09:17:09 -0700 |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2021-09-17 09:19:46 -0400 |
commit | de71511109d967000e68baedb75de104adb2b778 (patch) | |
tree | 132473fe6e5c4a248742d9a5a8ba75c7506dbe71 /absl/container/internal/raw_hash_set.h | |
parent | 2f25e6ea5f91d1646aca2337719c9b4deb64100a (diff) | |
download | abseil-de71511109d967000e68baedb75de104adb2b778.tar.gz abseil-de71511109d967000e68baedb75de104adb2b778.tar.bz2 abseil-de71511109d967000e68baedb75de104adb2b778.zip |
Export of internal Abseil changes
--
3794fe8db7a8e5a17945a8d6e198cde1db1fed7d by Chris Kennelly <ckennelly@google.com>:
Record maximum reserve or rehash argument in hashtable statistics.
This makes it possible to identify containers that are large because of reserve
calls or ones that could have an opportunity for more precise capacity sizing.
PiperOrigin-RevId: 396851064
--
c3d247c08acfd45d8e19cfd8e6e841e16e38e23d by Abseil Team <absl-team@google.com>:
Remove extra semi-colon
PiperOrigin-RevId: 396823800
GitOrigin-RevId: 3794fe8db7a8e5a17945a8d6e198cde1db1fed7d
Change-Id: I9f26407c2dc6b3dff04f6f3e249571dd8ab288c3
Diffstat (limited to 'absl/container/internal/raw_hash_set.h')
-rw-r--r-- | absl/container/internal/raw_hash_set.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index f4919ce3..212052ea 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -1069,6 +1069,8 @@ class raw_hash_set { // past that we simply deallocate the array. if (capacity_ > 127) { destroy_slots(); + + infoz().RecordClearedReservation(); } else if (capacity_) { for (size_t i = 0; i != capacity_; ++i) { if (IsFull(ctrl_[i])) { @@ -1382,14 +1384,20 @@ class raw_hash_set { if (n == 0 && size_ == 0) { destroy_slots(); infoz().RecordStorageChanged(0, 0); + infoz().RecordClearedReservation(); return; } + // bitor is a faster way of doing `max` here. We will round up to the next // power-of-2-minus-1, so bitor is good enough. auto m = NormalizeCapacity(n | GrowthToLowerboundCapacity(size())); // n == 0 unconditionally rehashes as per the standard. if (n == 0 || m > capacity_) { resize(m); + + // This is after resize, to ensure that we have completed the allocation + // and have potentially sampled the hashtable. + infoz().RecordReservation(n); } } @@ -1397,6 +1405,10 @@ class raw_hash_set { if (n > size() + growth_left()) { size_t m = GrowthToLowerboundCapacity(n); resize(NormalizeCapacity(m)); + + // This is after resize, to ensure that we have completed the allocation + // and have potentially sampled the hashtable. + infoz().RecordReservation(n); } } @@ -1638,6 +1650,7 @@ class raw_hash_set { PolicyTraits::destroy(&alloc_ref(), slots_ + i); } } + // Unpoison before returning the memory to the allocator. SanitizerUnpoisonMemoryRegion(slots_, sizeof(slot_type) * capacity_); Deallocate<alignof(slot_type)>( |