// Reports an allocation of the given size to perfetto. This should be // called for all allocations. Sampling is done internally to reduce the // performance overhead based on the sampling interval.
EXPORT void ReportAllocation(art::mirror::Object* obj, size_t allocation_size);
// Report a tlab allocation. This will adjust the allocation size based on // the number of bytes allocated in the thread local buffer since the last // sample was reported. // The allocation_size should be the size of the object being allocated. // pre_tlab_size should be the TlabSize() before the allocation, and // post_tlab_size should be the TlabSize() after the allocation. void ReportTlabAllocation(art::mirror::Object* obj,
size_t allocation_size,
size_t pre_tlab_size,
size_t post_tlab_size);
// Computes and records the next TLAB allocation size to use based on the // given target size. If profiling is enabled, the size is chosen randomly // based on the current sampling interval, otherwise the target is returned // directly.
size_t NextTlabSize(size_t target) REQUIRES(!rng_lock_) { return IsEnabled() ? NextRandomTlabSize(target) : target;
}
// Computes and records the next TLAB allocation size to use based on the // given target size, assuming profiling is enabled. The size is chosen // randomly based on the current sampling interval.
size_t NextRandomTlabSize(size_t target) REQUIRES(!rng_lock_);
// Is heap sampler enabled? bool IsEnabled() { return enabled_.load(std::memory_order_acquire); } // Set the sampling interval. void SetSamplingInterval(size_t sampling_interval); // Return the sampling interval.
size_t GetSamplingInterval();
private: // The number of bytes remaining in the thread local buffer that we have not // sampled yet. static thread_local size_t tlab_unsampled_bytes_;
std::atomic<bool> enabled_{false}; // Default sampling interval is 4kb.
std::atomic<size_t> p_sampling_interval_{4 * 1024};
uint32_t perfetto_heap_id_ = 0; // std random number generator.
std::minstd_rand rng_ GUARDED_BY(rng_lock_); // Holds the state // Multiple threads can access the random number generator concurrently and // thus rng_lock_ is used for thread safety.
art::Mutex rng_lock_;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.