Closed Bug 1149537 Opened 9 years ago Closed 9 years ago

Daily subsession splits should not occur before midnight

Categories

(Toolkit :: Telemetry, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox40 --- affected
firefox41 --- fixed

People

(Reporter: gfritzsche, Assigned: Dexter)

References

Details

(Whiteboard: [b5] [unifiedTelemetry])

Attachments

(2 files, 8 obsolete files)

(Benjamin Smedberg  [:bsmedberg] on bug 1139751, comment #18)
> I just want to check something here. It's important that no matter whether
> the ping is started before or after midnight, that the subsessionStartDate
> is for the correct day, so e.g.:
> 
> Monday       Midnight      Tuesday
> A          *                   B
> A                     *        B
> 
> no matter exactly when we split the subsession, "A" should have
> subsessionStartDate=Monday and "B" should have subsessionStartDate=Tuesday.
* if the user is active, we shouldnt miss midnight by more then 5 min on either side
* if the user is idle, we would be ok with missing midnight by 30 min
Per discussing things, we are best off if we simply don't submit daily pings before midnight.
That way we avoid data association issues in the first place and can use subsessionStartDate for identification.

A remaining concern for associating data with a specific day is a computer sleeping past midnight.
I will file a separate bug for triggering a session split on wakeup.
This patch changes the daily ping policy to generate a new daily ping only after midnight. Daily pings are no longer generated when the user is idle before midnight.
Assignee: nobody → alessio.placitelli
Status: NEW → ASSIGNED
Attachment #8613914 - Flags: review?(gfritzsche)
Attachment #8613914 - Flags: review?(gfritzsche)
Forgot to qref.
Attachment #8613914 - Attachment is obsolete: true
Attachment #8613935 - Flags: review?(gfritzsche)
Attachment #8613937 - Flags: review?(gfritzsche)
Comment on attachment 8613935 [details] [diff] [review]
part 1 - Only send daily pings after midnight

Review of attachment 8613935 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/telemetry/TelemetrySession.jsm
@@ +438,5 @@
>    _sentDailyPingToday: function(nowDate) {
>      // This is today's date and also the previous midnight (0:00).
>      const todayDate = Utils.truncateToDays(nowDate);
> +    // We consider a ping sent for today if it occured after midnight.
> +    return (this._lastDailyPingTime >= (todayDate.getTime() - SCHEDULER_MIDNIGHT_TOLERANCE_MS));

If we always create the daily ping after midnight, we don't need any tolerance in the calculation.

@@ +458,5 @@
>  
> +    const lastMidnight = Utils.truncateToDays(nowDate);
> +    const isOverdue =
> +      (nowDate.getTime() - lastMidnight.getTime()) > SCHEDULER_MIDNIGHT_TOLERANCE_MS;
> +    if (isOverdue) {

I don't think we need the overdue logic anymore.
Do you see a scenario where it is needed?
Attachment #8613935 - Flags: review?(gfritzsche)
Thanks Georg. I was thinking about a computer waking up from the sleep for the overdue but, as discussed over IRC, that case is already covered by the past midnight check.
Attachment #8613935 - Attachment is obsolete: true
Attachment #8614075 - Flags: review?(gfritzsche)
Comment on attachment 8614075 [details] [diff] [review]
part 1 - Only send daily pings after midnight - v2

Review of attachment 8614075 [details] [diff] [review]:
-----------------------------------------------------------------

One thing i missed before: as we don't happen to trigger the daily pings before midnight anymore, we should adjust the midnight fuzzing accordingly.

::: toolkit/components/telemetry/TelemetrySession.jsm
@@ +437,5 @@
>  
>    _sentDailyPingToday: function(nowDate) {
>      // This is today's date and also the previous midnight (0:00).
>      const todayDate = Utils.truncateToDays(nowDate);
> +    // We consider a ping sent for today if it occured after midnight.

"... after or at 00:00 today" or "... 12AM today".
Days start at 00:00 and run up to, exclusive, 24:00 (start of next day).
Attachment #8614075 - Flags: review?(gfritzsche)
This patch changes the fuzzing function to delay pings, within the fuzzing range, after midnight.
Attachment #8614075 - Attachment is obsolete: true
Attachment #8614526 - Flags: review?(gfritzsche)
Updated the patch to fix the broken midnight fuzzing test.
Attachment #8613937 - Attachment is obsolete: true
Attachment #8613937 - Flags: review?(gfritzsche)
Attachment #8614527 - Flags: review?(gfritzsche)
Sorry, I attached the wrong patch.
Attachment #8614526 - Attachment is obsolete: true
Attachment #8614526 - Flags: review?(gfritzsche)
Attachment #8614551 - Flags: review?(gfritzsche)
Same here.
Attachment #8614527 - Attachment is obsolete: true
Attachment #8614527 - Flags: review?(gfritzsche)
Attachment #8614552 - Flags: review?(gfritzsche)
Comment on attachment 8614551 [details] [diff] [review]
part 1 - Only send daily pings after midnight - v3

Review of attachment 8614551 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/telemetry/TelemetryController.jsm
@@ +502,5 @@
>    },
>  
>    /**
>     * This helper calculates the next time that we can send pings at.
> +   * Currently this mostly redistributes ping sends after midnight to avoid submission

It should not be "after", the spike starts at 00:00.
"... from midnight until one hour after ..."

@@ +520,1 @@
>      // Don't delay ping if we are not close to midnight.

This comment needs updating.

::: toolkit/components/telemetry/TelemetrySession.jsm
@@ +447,5 @@
>     * @param {Object} nowDate A date object.
>     * @return {Boolean} True if we can send the daily ping, false otherwise.
>     */
>    _isDailyPingDue: function(nowDate) {
>      const sentPingToday = this._sentDailyPingToday(nowDate);

Nit: we don't use sentPingToday anywhere else here, we can just move it down below the comment on line 453 to make that clearer or just move the call into the condition.
Attachment #8614551 - Flags: review?(gfritzsche) → review+
Thanks Georg. As discussed, this will land after the sending logic refactoring lands.
Attachment #8614551 - Attachment is obsolete: true
Attachment #8614586 - Flags: review+
Comment on attachment 8614552 [details] [diff] [review]
part 2 - Remove the daily on idle test - v2

Review of attachment 8614552 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with the below addressed.

::: toolkit/components/telemetry/tests/unit/test_TelemetryController.js
@@ +281,5 @@
>  
>    gRequestIterator = Iterator(new Request());
>    yield TelemetryController.reset();
>  
>    // A ping submitted shortly before midnight should not get sent yet.

This comment is a left-over now, you want to move the ping handler down to where it's used too.

@@ -283,5 @@
>    yield TelemetryController.reset();
>  
>    // A ping submitted shortly before midnight should not get sent yet.
> -  now = new Date(2030, 5, 1, 23, 55, 0);
> -  fakeNow(now);

Let's instead do a check that we *do* send shortly before midnight now (23:59).

@@ +289,3 @@
>  
>    // A ping after midnight within the fuzzing delay should also not get sent.
>    now = new Date(2030, 5, 2, 0, 40, 0);

Let's add another check for not sending right before the end of the fuzzing delay too.
Attachment #8614552 - Flags: review?(gfritzsche) → review+
Attachment #8614552 - Attachment is obsolete: true
Attachment #8614699 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/1fe7dce1c609
https://hg.mozilla.org/mozilla-central/rev/ea849f73f3c9
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Whiteboard: [uplift]
Whiteboard: [uplift] → [uplift2]
Whiteboard: [uplift2] → [b5] [unifiedTelemetry] [uplift2]
Whiteboard: [b5] [unifiedTelemetry] [uplift2] → [b5] [unifiedTelemetry]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: