size_t HeapSampler::NextRandomTlabSize(size_t target) { // Scale the target tlab size by sampling interval, so the cost of // profiling can be reduced by increasing the sampling interval. // The factor 1/8 is somewhat arbitrarily chosen to avoid interfering with // Perfetto's subsequent sampling of the allocations when we call // AHeapProfile_reportAllocation.
target = std::min(target, GetSamplingInterval() / 8); if (target == 0) {
target = 1;
}
// Draw randomly from exponential distribution with the goal of having // equal probability of sampling any given byte. This is the same logic // used in AHeapProfile_reportAllocation for sampling. double rate = 1.0 / static_cast<double>(target);
std::exponential_distribution<double> dist(rate);
art::MutexLock mu(art::Thread::Current(), rng_lock_);
int64_t next = static_cast<int64_t>(dist(rng_)); return next + 1;
}
void HeapSampler::ReportTlabAllocation(art::mirror::Object* obj,
size_t allocation_size,
size_t pre_tlab_size,
size_t post_tlab_size) { if (pre_tlab_size > tlab_unsampled_bytes_) { // In theory pre_tlab_size shouldn't exceed tlab_unsampled_bytes_. In // practice our tlab_unsampled_bytes_ could be out of date if profiling // was disabled/enabled since we last set it. Ignore the previously // allocated bytes in that case.
pre_tlab_size = 0;
tlab_unsampled_bytes_ = 0;
}
size_t adjusted_size = allocation_size + tlab_unsampled_bytes_ - pre_tlab_size;
tlab_unsampled_bytes_ = post_tlab_size;
ReportAllocation(obj, adjusted_size);
}
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.