Commit f6bbacad authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[Throughput UKM] Correct sampling logic

We have identified that the reason of not getting throughput UKM is
due to the sampling logic, via this debug CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1946872

This CL changes the sampling logic.

Bug: 1029964
Change-Id: Icf5fc750102d0e3631047913d77adb4e37589721
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1958195Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723642}
parent cbbe680e
......@@ -10,7 +10,7 @@ namespace cc {
namespace {
// Collect UKM once per kNumberOfSamplesToReport UMA reports.
constexpr unsigned kNumberOfSamplesToReport = 2000u;
constexpr unsigned kNumberOfSamplesToReport = 100u;
} // namespace
void ThroughputUkmReporter::ReportThroughputUkm(
......@@ -19,17 +19,12 @@ void ThroughputUkmReporter::ReportThroughputUkm(
const base::Optional<int>& impl_throughput_percent,
const base::Optional<int>& main_throughput_percent,
FrameSequenceTrackerType type) {
// Sampling control. We sample the event here to not throttle the UKM system.
// Currently, the same sampling rate is applied to all existing trackers. We
// might want to iterate on this based on the collected data.
static uint32_t samples_to_next_event = 0;
if (samples_to_next_event == 0) {
if (samples_to_next_event_ == 0) {
// Sample every 2000 events. Using the Universal tracker as an example
// which reports UMA every 5s, then the system collects UKM once per
// 2000*5 = 10000 seconds, which is about 3 hours. This number may need to
// be tuned to not throttle the UKM system.
samples_to_next_event = kNumberOfSamplesToReport;
samples_to_next_event_ = kNumberOfSamplesToReport;
if (impl_throughput_percent) {
ukm_manager->RecordThroughputUKM(
type, FrameSequenceTracker::ThreadType::kCompositor,
......@@ -44,8 +39,8 @@ void ThroughputUkmReporter::ReportThroughputUkm(
FrameSequenceTracker::ThreadType::kSlower,
slower_throughput_percent.value());
}
DCHECK_GT(samples_to_next_event, 0u);
samples_to_next_event--;
DCHECK_GT(samples_to_next_event_, 0u);
samples_to_next_event_--;
}
} // namespace cc
......@@ -24,6 +24,12 @@ class CC_EXPORT ThroughputUkmReporter {
const base::Optional<int>& impl_throughput_percent,
const base::Optional<int>& main_throughput_percent,
FrameSequenceTrackerType type);
private:
// Sampling control. We sample the event here to not throttle the UKM system.
// Currently, the same sampling rate is applied to all existing trackers. We
// might want to iterate on this based on the collected data.
uint32_t samples_to_next_event_ = 0;
};
} // namespace cc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment