New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 860413 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jul 5
Cc:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

Recent Events Counter gives zero shortly after logging

Project Member Reported by pdyson@chromium.org, Jul 5

Issue description

Chrome Version: 68 beta
OS: ChromeOS

What steps will reproduce the problem?

base::TimeDelta minute = base::TimeDelta::FromMinutes(1);
RecentEventsCounter counter(base::TimeDelta::FromHours(1), 60);

counter.Log(65 * minute);
counter.Log(66 * minute);
int a = counter.GetTotal(66 * minute);
int b = counter.GetTotal(66.5 * minute);

What is the expected result?
a and b should both be 2.

What happens instead?
a and b are both zero.

We are using a circular array to store the values for each minute.
The problem is reading the entire array. We need to read from
minute 6, up to minute 59, then from minute 0 up to minute 5. The code says start at minute 6 and keep going and until you get to minute 6. Unfortunately, we are already at minute 6 at the beginning so we never loop around the array.

 
Paul, I don't think this is a UKM bug? Can you put in the right component
Project Member

Comment 2 by bugdroid1@chromium.org, Jul 5

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8c60d6ca33741c742470e7851c056b8105980d12

commit 8c60d6ca33741c742470e7851c056b8105980d12
Author: Paul Dyson <pdyson@chromium.org>
Date: Thu Jul 05 23:27:43 2018

Fix RecentEventsCounter looping error.

When GetBucketIndex(start) == end_index we want to sum the entire array,
but we end up summing none of the array.

We need a way to sum all the elements of event_count_. That can never
happen if the loop never iterates for i == end_index. event_count_[end_index]
is never part of the sum.

Bug:  860413 
Change-Id: I5c6f65f427b71d2103374cf1bfcee533ac91979e
Reviewed-on: https://chromium-review.googlesource.com/1126803
Reviewed-by: Dan Erat <derat@chromium.org>
Reviewed-by: Jia Meng <jiameng@chromium.org>
Commit-Queue: Paul Dyson <pdyson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572868}
[modify] https://crrev.com/8c60d6ca33741c742470e7851c056b8105980d12/chrome/browser/chromeos/power/ml/recent_events_counter.cc
[modify] https://crrev.com/8c60d6ca33741c742470e7851c056b8105980d12/chrome/browser/chromeos/power/ml/recent_events_counter_unittest.cc

Components: -Internals>Metrics>UKM
Status: Fixed (was: Started)

Sign in to add a comment