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

[throughput] Avoid reporting underflow cases

Right now we report throughput to UMA whenever the number of expected
frames are >= 100.

This CL added a condition to prevent underflow. That is, the frames
expected could be decremented to be < 0, but given that the type of
frames_expected is uint64_t, we will get a very large number instead
of < 0.

Bug: 1021963
Change-Id: I2ec718545fa4913e941d2492c622df8144477512
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010183Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741431}
parent 75b5db21
......@@ -60,6 +60,8 @@ namespace {
// Avoid reporting any throughput metric for sequences that do not have a
// sufficient number of frames.
constexpr int kMinFramesForThroughputMetric = 100;
// Used to avoid reporting throughput when it underflows.
constexpr unsigned kMaxFramesForThroughputMetric = 6000;
constexpr int kBuiltinSequenceNum = FrameSequenceTrackerType::kMaxType + 1;
constexpr int kMaximumHistogramIndex = 3 * kBuiltinSequenceNum;
......@@ -465,6 +467,9 @@ void FrameSequenceTracker::ScheduleTerminate() {
// It could happen that a main/impl frame is generated, but never processed
// (didn't report no damage and didn't submit) when this happens.
if (last_processed_impl_sequence_ < last_started_impl_sequence_) {
DCHECK_GE(impl_throughput().frames_expected,
begin_impl_frame_data_.previous_sequence_delta)
<< TRACKER_DCHECK_MSG;
impl_throughput().frames_expected -=
begin_impl_frame_data_.previous_sequence_delta;
#if DCHECK_IS_ON()
......@@ -962,7 +967,9 @@ base::Optional<int> FrameSequenceMetrics::ThroughputData::ReportHistogram(
GetFrameSequenceLengthHistogramName(sequence_type), 1, 1000, 50,
base::HistogramBase::kUmaTargetedHistogramFlag));
if (data.frames_expected < kMinFramesForThroughputMetric)
DCHECK_LT(data.frames_expected, kMaxFramesForThroughputMetric);
if (data.frames_expected < kMinFramesForThroughputMetric ||
data.frames_expected > kMaxFramesForThroughputMetric)
return base::nullopt;
const int percent =
......
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