xref: /aosp_15_r20/external/abseil-cpp/absl/container/internal/hashtablez_sampler.h (revision 9356374a3709195abf420251b3e825997ff56c0f)
1*9356374aSAndroid Build Coastguard Worker // Copyright 2018 The Abseil Authors.
2*9356374aSAndroid Build Coastguard Worker //
3*9356374aSAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*9356374aSAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*9356374aSAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*9356374aSAndroid Build Coastguard Worker //
7*9356374aSAndroid Build Coastguard Worker //      https://www.apache.org/licenses/LICENSE-2.0
8*9356374aSAndroid Build Coastguard Worker //
9*9356374aSAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*9356374aSAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*9356374aSAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*9356374aSAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*9356374aSAndroid Build Coastguard Worker // limitations under the License.
14*9356374aSAndroid Build Coastguard Worker //
15*9356374aSAndroid Build Coastguard Worker // -----------------------------------------------------------------------------
16*9356374aSAndroid Build Coastguard Worker // File: hashtablez_sampler.h
17*9356374aSAndroid Build Coastguard Worker // -----------------------------------------------------------------------------
18*9356374aSAndroid Build Coastguard Worker //
19*9356374aSAndroid Build Coastguard Worker // This header file defines the API for a low level library to sample hashtables
20*9356374aSAndroid Build Coastguard Worker // and collect runtime statistics about them.
21*9356374aSAndroid Build Coastguard Worker //
22*9356374aSAndroid Build Coastguard Worker // `HashtablezSampler` controls the lifecycle of `HashtablezInfo` objects which
23*9356374aSAndroid Build Coastguard Worker // store information about a single sample.
24*9356374aSAndroid Build Coastguard Worker //
25*9356374aSAndroid Build Coastguard Worker // `Record*` methods store information into samples.
26*9356374aSAndroid Build Coastguard Worker // `Sample()` and `Unsample()` make use of a single global sampler with
27*9356374aSAndroid Build Coastguard Worker // properties controlled by the flags hashtablez_enabled,
28*9356374aSAndroid Build Coastguard Worker // hashtablez_sample_rate, and hashtablez_max_samples.
29*9356374aSAndroid Build Coastguard Worker //
30*9356374aSAndroid Build Coastguard Worker // WARNING
31*9356374aSAndroid Build Coastguard Worker //
32*9356374aSAndroid Build Coastguard Worker // Using this sampling API may cause sampled Swiss tables to use the global
33*9356374aSAndroid Build Coastguard Worker // allocator (operator `new`) in addition to any custom allocator.  If you
34*9356374aSAndroid Build Coastguard Worker // are using a table in an unusual circumstance where allocation or calling a
35*9356374aSAndroid Build Coastguard Worker // linux syscall is unacceptable, this could interfere.
36*9356374aSAndroid Build Coastguard Worker //
37*9356374aSAndroid Build Coastguard Worker // This utility is internal-only. Use at your own risk.
38*9356374aSAndroid Build Coastguard Worker 
39*9356374aSAndroid Build Coastguard Worker #ifndef ABSL_CONTAINER_INTERNAL_HASHTABLEZ_SAMPLER_H_
40*9356374aSAndroid Build Coastguard Worker #define ABSL_CONTAINER_INTERNAL_HASHTABLEZ_SAMPLER_H_
41*9356374aSAndroid Build Coastguard Worker 
42*9356374aSAndroid Build Coastguard Worker #include <atomic>
43*9356374aSAndroid Build Coastguard Worker #include <cstddef>
44*9356374aSAndroid Build Coastguard Worker #include <cstdint>
45*9356374aSAndroid Build Coastguard Worker #include <functional>
46*9356374aSAndroid Build Coastguard Worker #include <memory>
47*9356374aSAndroid Build Coastguard Worker #include <vector>
48*9356374aSAndroid Build Coastguard Worker 
49*9356374aSAndroid Build Coastguard Worker #include "absl/base/attributes.h"
50*9356374aSAndroid Build Coastguard Worker #include "absl/base/config.h"
51*9356374aSAndroid Build Coastguard Worker #include "absl/base/internal/per_thread_tls.h"
52*9356374aSAndroid Build Coastguard Worker #include "absl/base/optimization.h"
53*9356374aSAndroid Build Coastguard Worker #include "absl/base/thread_annotations.h"
54*9356374aSAndroid Build Coastguard Worker #include "absl/profiling/internal/sample_recorder.h"
55*9356374aSAndroid Build Coastguard Worker #include "absl/synchronization/mutex.h"
56*9356374aSAndroid Build Coastguard Worker #include "absl/time/time.h"
57*9356374aSAndroid Build Coastguard Worker #include "absl/utility/utility.h"
58*9356374aSAndroid Build Coastguard Worker 
59*9356374aSAndroid Build Coastguard Worker namespace absl {
60*9356374aSAndroid Build Coastguard Worker ABSL_NAMESPACE_BEGIN
61*9356374aSAndroid Build Coastguard Worker namespace container_internal {
62*9356374aSAndroid Build Coastguard Worker 
63*9356374aSAndroid Build Coastguard Worker // Stores information about a sampled hashtable.  All mutations to this *must*
64*9356374aSAndroid Build Coastguard Worker // be made through `Record*` functions below.  All reads from this *must* only
65*9356374aSAndroid Build Coastguard Worker // occur in the callback to `HashtablezSampler::Iterate`.
66*9356374aSAndroid Build Coastguard Worker struct HashtablezInfo : public profiling_internal::Sample<HashtablezInfo> {
67*9356374aSAndroid Build Coastguard Worker   // Constructs the object but does not fill in any fields.
68*9356374aSAndroid Build Coastguard Worker   HashtablezInfo();
69*9356374aSAndroid Build Coastguard Worker   ~HashtablezInfo();
70*9356374aSAndroid Build Coastguard Worker   HashtablezInfo(const HashtablezInfo&) = delete;
71*9356374aSAndroid Build Coastguard Worker   HashtablezInfo& operator=(const HashtablezInfo&) = delete;
72*9356374aSAndroid Build Coastguard Worker 
73*9356374aSAndroid Build Coastguard Worker   // Puts the object into a clean state, fills in the logically `const` members,
74*9356374aSAndroid Build Coastguard Worker   // blocking for any readers that are currently sampling the object.
75*9356374aSAndroid Build Coastguard Worker   void PrepareForSampling(int64_t stride, size_t inline_element_size_value,
76*9356374aSAndroid Build Coastguard Worker                           size_t key_size, size_t value_size,
77*9356374aSAndroid Build Coastguard Worker                           uint16_t soo_capacity_value)
78*9356374aSAndroid Build Coastguard Worker       ABSL_EXCLUSIVE_LOCKS_REQUIRED(init_mu);
79*9356374aSAndroid Build Coastguard Worker 
80*9356374aSAndroid Build Coastguard Worker   // These fields are mutated by the various Record* APIs and need to be
81*9356374aSAndroid Build Coastguard Worker   // thread-safe.
82*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> capacity;
83*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> size;
84*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> num_erases;
85*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> num_rehashes;
86*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> max_probe_length;
87*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> total_probe_length;
88*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> hashes_bitwise_or;
89*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> hashes_bitwise_and;
90*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> hashes_bitwise_xor;
91*9356374aSAndroid Build Coastguard Worker   std::atomic<size_t> max_reserve;
92*9356374aSAndroid Build Coastguard Worker 
93*9356374aSAndroid Build Coastguard Worker   // All of the fields below are set by `PrepareForSampling`, they must not be
94*9356374aSAndroid Build Coastguard Worker   // mutated in `Record*` functions.  They are logically `const` in that sense.
95*9356374aSAndroid Build Coastguard Worker   // These are guarded by init_mu, but that is not externalized to clients,
96*9356374aSAndroid Build Coastguard Worker   // which can read them only during `SampleRecorder::Iterate` which will hold
97*9356374aSAndroid Build Coastguard Worker   // the lock.
98*9356374aSAndroid Build Coastguard Worker   static constexpr int kMaxStackDepth = 64;
99*9356374aSAndroid Build Coastguard Worker   absl::Time create_time;
100*9356374aSAndroid Build Coastguard Worker   int32_t depth;
101*9356374aSAndroid Build Coastguard Worker   // The SOO capacity for this table in elements (not bytes). Note that sampled
102*9356374aSAndroid Build Coastguard Worker   // tables are never SOO because we need to store the infoz handle on the heap.
103*9356374aSAndroid Build Coastguard Worker   // Tables that would be SOO if not sampled should have: soo_capacity > 0 &&
104*9356374aSAndroid Build Coastguard Worker   // size <= soo_capacity && max_reserve <= soo_capacity.
105*9356374aSAndroid Build Coastguard Worker   uint16_t soo_capacity;
106*9356374aSAndroid Build Coastguard Worker   void* stack[kMaxStackDepth];
107*9356374aSAndroid Build Coastguard Worker   size_t inline_element_size;  // How big is the slot in bytes?
108*9356374aSAndroid Build Coastguard Worker   size_t key_size;             // sizeof(key_type)
109*9356374aSAndroid Build Coastguard Worker   size_t value_size;           // sizeof(value_type)
110*9356374aSAndroid Build Coastguard Worker };
111*9356374aSAndroid Build Coastguard Worker 
112*9356374aSAndroid Build Coastguard Worker void RecordRehashSlow(HashtablezInfo* info, size_t total_probe_length);
113*9356374aSAndroid Build Coastguard Worker 
114*9356374aSAndroid Build Coastguard Worker void RecordReservationSlow(HashtablezInfo* info, size_t target_capacity);
115*9356374aSAndroid Build Coastguard Worker 
116*9356374aSAndroid Build Coastguard Worker void RecordClearedReservationSlow(HashtablezInfo* info);
117*9356374aSAndroid Build Coastguard Worker 
118*9356374aSAndroid Build Coastguard Worker void RecordStorageChangedSlow(HashtablezInfo* info, size_t size,
119*9356374aSAndroid Build Coastguard Worker                               size_t capacity);
120*9356374aSAndroid Build Coastguard Worker 
121*9356374aSAndroid Build Coastguard Worker void RecordInsertSlow(HashtablezInfo* info, size_t hash,
122*9356374aSAndroid Build Coastguard Worker                       size_t distance_from_desired);
123*9356374aSAndroid Build Coastguard Worker 
124*9356374aSAndroid Build Coastguard Worker void RecordEraseSlow(HashtablezInfo* info);
125*9356374aSAndroid Build Coastguard Worker 
126*9356374aSAndroid Build Coastguard Worker struct SamplingState {
127*9356374aSAndroid Build Coastguard Worker   int64_t next_sample;
128*9356374aSAndroid Build Coastguard Worker   // When we make a sampling decision, we record that distance so we can weight
129*9356374aSAndroid Build Coastguard Worker   // each sample.
130*9356374aSAndroid Build Coastguard Worker   int64_t sample_stride;
131*9356374aSAndroid Build Coastguard Worker };
132*9356374aSAndroid Build Coastguard Worker 
133*9356374aSAndroid Build Coastguard Worker HashtablezInfo* SampleSlow(SamplingState& next_sample,
134*9356374aSAndroid Build Coastguard Worker                            size_t inline_element_size, size_t key_size,
135*9356374aSAndroid Build Coastguard Worker                            size_t value_size, uint16_t soo_capacity);
136*9356374aSAndroid Build Coastguard Worker void UnsampleSlow(HashtablezInfo* info);
137*9356374aSAndroid Build Coastguard Worker 
138*9356374aSAndroid Build Coastguard Worker #if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
139*9356374aSAndroid Build Coastguard Worker #error ABSL_INTERNAL_HASHTABLEZ_SAMPLE cannot be directly set
140*9356374aSAndroid Build Coastguard Worker #endif  // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
141*9356374aSAndroid Build Coastguard Worker 
142*9356374aSAndroid Build Coastguard Worker #if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
143*9356374aSAndroid Build Coastguard Worker class HashtablezInfoHandle {
144*9356374aSAndroid Build Coastguard Worker  public:
HashtablezInfoHandle()145*9356374aSAndroid Build Coastguard Worker   explicit HashtablezInfoHandle() : info_(nullptr) {}
HashtablezInfoHandle(HashtablezInfo * info)146*9356374aSAndroid Build Coastguard Worker   explicit HashtablezInfoHandle(HashtablezInfo* info) : info_(info) {}
147*9356374aSAndroid Build Coastguard Worker 
148*9356374aSAndroid Build Coastguard Worker   // We do not have a destructor. Caller is responsible for calling Unregister
149*9356374aSAndroid Build Coastguard Worker   // before destroying the handle.
Unregister()150*9356374aSAndroid Build Coastguard Worker   void Unregister() {
151*9356374aSAndroid Build Coastguard Worker     if (ABSL_PREDICT_TRUE(info_ == nullptr)) return;
152*9356374aSAndroid Build Coastguard Worker     UnsampleSlow(info_);
153*9356374aSAndroid Build Coastguard Worker   }
154*9356374aSAndroid Build Coastguard Worker 
IsSampled()155*9356374aSAndroid Build Coastguard Worker   inline bool IsSampled() const { return ABSL_PREDICT_FALSE(info_ != nullptr); }
156*9356374aSAndroid Build Coastguard Worker 
RecordStorageChanged(size_t size,size_t capacity)157*9356374aSAndroid Build Coastguard Worker   inline void RecordStorageChanged(size_t size, size_t capacity) {
158*9356374aSAndroid Build Coastguard Worker     if (ABSL_PREDICT_TRUE(info_ == nullptr)) return;
159*9356374aSAndroid Build Coastguard Worker     RecordStorageChangedSlow(info_, size, capacity);
160*9356374aSAndroid Build Coastguard Worker   }
161*9356374aSAndroid Build Coastguard Worker 
RecordRehash(size_t total_probe_length)162*9356374aSAndroid Build Coastguard Worker   inline void RecordRehash(size_t total_probe_length) {
163*9356374aSAndroid Build Coastguard Worker     if (ABSL_PREDICT_TRUE(info_ == nullptr)) return;
164*9356374aSAndroid Build Coastguard Worker     RecordRehashSlow(info_, total_probe_length);
165*9356374aSAndroid Build Coastguard Worker   }
166*9356374aSAndroid Build Coastguard Worker 
RecordReservation(size_t target_capacity)167*9356374aSAndroid Build Coastguard Worker   inline void RecordReservation(size_t target_capacity) {
168*9356374aSAndroid Build Coastguard Worker     if (ABSL_PREDICT_TRUE(info_ == nullptr)) return;
169*9356374aSAndroid Build Coastguard Worker     RecordReservationSlow(info_, target_capacity);
170*9356374aSAndroid Build Coastguard Worker   }
171*9356374aSAndroid Build Coastguard Worker 
RecordClearedReservation()172*9356374aSAndroid Build Coastguard Worker   inline void RecordClearedReservation() {
173*9356374aSAndroid Build Coastguard Worker     if (ABSL_PREDICT_TRUE(info_ == nullptr)) return;
174*9356374aSAndroid Build Coastguard Worker     RecordClearedReservationSlow(info_);
175*9356374aSAndroid Build Coastguard Worker   }
176*9356374aSAndroid Build Coastguard Worker 
RecordInsert(size_t hash,size_t distance_from_desired)177*9356374aSAndroid Build Coastguard Worker   inline void RecordInsert(size_t hash, size_t distance_from_desired) {
178*9356374aSAndroid Build Coastguard Worker     if (ABSL_PREDICT_TRUE(info_ == nullptr)) return;
179*9356374aSAndroid Build Coastguard Worker     RecordInsertSlow(info_, hash, distance_from_desired);
180*9356374aSAndroid Build Coastguard Worker   }
181*9356374aSAndroid Build Coastguard Worker 
RecordErase()182*9356374aSAndroid Build Coastguard Worker   inline void RecordErase() {
183*9356374aSAndroid Build Coastguard Worker     if (ABSL_PREDICT_TRUE(info_ == nullptr)) return;
184*9356374aSAndroid Build Coastguard Worker     RecordEraseSlow(info_);
185*9356374aSAndroid Build Coastguard Worker   }
186*9356374aSAndroid Build Coastguard Worker 
swap(HashtablezInfoHandle & lhs,HashtablezInfoHandle & rhs)187*9356374aSAndroid Build Coastguard Worker   friend inline void swap(HashtablezInfoHandle& lhs,
188*9356374aSAndroid Build Coastguard Worker                           HashtablezInfoHandle& rhs) {
189*9356374aSAndroid Build Coastguard Worker     std::swap(lhs.info_, rhs.info_);
190*9356374aSAndroid Build Coastguard Worker   }
191*9356374aSAndroid Build Coastguard Worker 
192*9356374aSAndroid Build Coastguard Worker  private:
193*9356374aSAndroid Build Coastguard Worker   friend class HashtablezInfoHandlePeer;
194*9356374aSAndroid Build Coastguard Worker   HashtablezInfo* info_;
195*9356374aSAndroid Build Coastguard Worker };
196*9356374aSAndroid Build Coastguard Worker #else
197*9356374aSAndroid Build Coastguard Worker // Ensure that when Hashtablez is turned off at compile time, HashtablezInfo can
198*9356374aSAndroid Build Coastguard Worker // be removed by the linker, in order to reduce the binary size.
199*9356374aSAndroid Build Coastguard Worker class HashtablezInfoHandle {
200*9356374aSAndroid Build Coastguard Worker  public:
201*9356374aSAndroid Build Coastguard Worker   explicit HashtablezInfoHandle() = default;
HashtablezInfoHandle(std::nullptr_t)202*9356374aSAndroid Build Coastguard Worker   explicit HashtablezInfoHandle(std::nullptr_t) {}
203*9356374aSAndroid Build Coastguard Worker 
Unregister()204*9356374aSAndroid Build Coastguard Worker   inline void Unregister() {}
IsSampled()205*9356374aSAndroid Build Coastguard Worker   inline bool IsSampled() const { return false; }
RecordStorageChanged(size_t,size_t)206*9356374aSAndroid Build Coastguard Worker   inline void RecordStorageChanged(size_t /*size*/, size_t /*capacity*/) {}
RecordRehash(size_t)207*9356374aSAndroid Build Coastguard Worker   inline void RecordRehash(size_t /*total_probe_length*/) {}
RecordReservation(size_t)208*9356374aSAndroid Build Coastguard Worker   inline void RecordReservation(size_t /*target_capacity*/) {}
RecordClearedReservation()209*9356374aSAndroid Build Coastguard Worker   inline void RecordClearedReservation() {}
RecordInsert(size_t,size_t)210*9356374aSAndroid Build Coastguard Worker   inline void RecordInsert(size_t /*hash*/, size_t /*distance_from_desired*/) {}
RecordErase()211*9356374aSAndroid Build Coastguard Worker   inline void RecordErase() {}
212*9356374aSAndroid Build Coastguard Worker 
swap(HashtablezInfoHandle &,HashtablezInfoHandle &)213*9356374aSAndroid Build Coastguard Worker   friend inline void swap(HashtablezInfoHandle& /*lhs*/,
214*9356374aSAndroid Build Coastguard Worker                           HashtablezInfoHandle& /*rhs*/) {}
215*9356374aSAndroid Build Coastguard Worker };
216*9356374aSAndroid Build Coastguard Worker #endif  // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
217*9356374aSAndroid Build Coastguard Worker 
218*9356374aSAndroid Build Coastguard Worker #if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
219*9356374aSAndroid Build Coastguard Worker extern ABSL_PER_THREAD_TLS_KEYWORD SamplingState global_next_sample;
220*9356374aSAndroid Build Coastguard Worker #endif  // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
221*9356374aSAndroid Build Coastguard Worker 
222*9356374aSAndroid Build Coastguard Worker // Returns a sampling handle.
Sample(ABSL_ATTRIBUTE_UNUSED size_t inline_element_size,ABSL_ATTRIBUTE_UNUSED size_t key_size,ABSL_ATTRIBUTE_UNUSED size_t value_size,ABSL_ATTRIBUTE_UNUSED uint16_t soo_capacity)223*9356374aSAndroid Build Coastguard Worker inline HashtablezInfoHandle Sample(
224*9356374aSAndroid Build Coastguard Worker     ABSL_ATTRIBUTE_UNUSED size_t inline_element_size,
225*9356374aSAndroid Build Coastguard Worker     ABSL_ATTRIBUTE_UNUSED size_t key_size,
226*9356374aSAndroid Build Coastguard Worker     ABSL_ATTRIBUTE_UNUSED size_t value_size,
227*9356374aSAndroid Build Coastguard Worker     ABSL_ATTRIBUTE_UNUSED uint16_t soo_capacity) {
228*9356374aSAndroid Build Coastguard Worker #if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
229*9356374aSAndroid Build Coastguard Worker   if (ABSL_PREDICT_TRUE(--global_next_sample.next_sample > 0)) {
230*9356374aSAndroid Build Coastguard Worker     return HashtablezInfoHandle(nullptr);
231*9356374aSAndroid Build Coastguard Worker   }
232*9356374aSAndroid Build Coastguard Worker   return HashtablezInfoHandle(SampleSlow(global_next_sample,
233*9356374aSAndroid Build Coastguard Worker                                          inline_element_size, key_size,
234*9356374aSAndroid Build Coastguard Worker                                          value_size, soo_capacity));
235*9356374aSAndroid Build Coastguard Worker #else
236*9356374aSAndroid Build Coastguard Worker   return HashtablezInfoHandle(nullptr);
237*9356374aSAndroid Build Coastguard Worker #endif  // !ABSL_PER_THREAD_TLS
238*9356374aSAndroid Build Coastguard Worker }
239*9356374aSAndroid Build Coastguard Worker 
240*9356374aSAndroid Build Coastguard Worker using HashtablezSampler =
241*9356374aSAndroid Build Coastguard Worker     ::absl::profiling_internal::SampleRecorder<HashtablezInfo>;
242*9356374aSAndroid Build Coastguard Worker 
243*9356374aSAndroid Build Coastguard Worker // Returns a global Sampler.
244*9356374aSAndroid Build Coastguard Worker HashtablezSampler& GlobalHashtablezSampler();
245*9356374aSAndroid Build Coastguard Worker 
246*9356374aSAndroid Build Coastguard Worker using HashtablezConfigListener = void (*)();
247*9356374aSAndroid Build Coastguard Worker void SetHashtablezConfigListener(HashtablezConfigListener l);
248*9356374aSAndroid Build Coastguard Worker 
249*9356374aSAndroid Build Coastguard Worker // Enables or disables sampling for Swiss tables.
250*9356374aSAndroid Build Coastguard Worker bool IsHashtablezEnabled();
251*9356374aSAndroid Build Coastguard Worker void SetHashtablezEnabled(bool enabled);
252*9356374aSAndroid Build Coastguard Worker void SetHashtablezEnabledInternal(bool enabled);
253*9356374aSAndroid Build Coastguard Worker 
254*9356374aSAndroid Build Coastguard Worker // Sets the rate at which Swiss tables will be sampled.
255*9356374aSAndroid Build Coastguard Worker int32_t GetHashtablezSampleParameter();
256*9356374aSAndroid Build Coastguard Worker void SetHashtablezSampleParameter(int32_t rate);
257*9356374aSAndroid Build Coastguard Worker void SetHashtablezSampleParameterInternal(int32_t rate);
258*9356374aSAndroid Build Coastguard Worker 
259*9356374aSAndroid Build Coastguard Worker // Sets a soft max for the number of samples that will be kept.
260*9356374aSAndroid Build Coastguard Worker size_t GetHashtablezMaxSamples();
261*9356374aSAndroid Build Coastguard Worker void SetHashtablezMaxSamples(size_t max);
262*9356374aSAndroid Build Coastguard Worker void SetHashtablezMaxSamplesInternal(size_t max);
263*9356374aSAndroid Build Coastguard Worker 
264*9356374aSAndroid Build Coastguard Worker // Configuration override.
265*9356374aSAndroid Build Coastguard Worker // This allows process-wide sampling without depending on order of
266*9356374aSAndroid Build Coastguard Worker // initialization of static storage duration objects.
267*9356374aSAndroid Build Coastguard Worker // The definition of this constant is weak, which allows us to inject a
268*9356374aSAndroid Build Coastguard Worker // different value for it at link time.
269*9356374aSAndroid Build Coastguard Worker extern "C" bool ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)();
270*9356374aSAndroid Build Coastguard Worker 
271*9356374aSAndroid Build Coastguard Worker }  // namespace container_internal
272*9356374aSAndroid Build Coastguard Worker ABSL_NAMESPACE_END
273*9356374aSAndroid Build Coastguard Worker }  // namespace absl
274*9356374aSAndroid Build Coastguard Worker 
275*9356374aSAndroid Build Coastguard Worker #endif  // ABSL_CONTAINER_INTERNAL_HASHTABLEZ_SAMPLER_H_
276