Bug 1614861 - Make slow startup notification bar sampler use monotonic clock. r=gsvelto

The slow startup notification bar sampler code was using
`Date.now() - Services.startup.getStartupInfo().process`.

`Services.startup.getStartupInfo().process` is a high-resolution timestamp from a
monotonic clock that has been converted to a Date object. Date.now() is a timestamp
from a clock that is _not guaranteed to be monotonic_, so even though they're technically
the same type, Date.now() ultimately has looser guarantees on its stability.

Date.now() can, for example, change if the OS communicates with a clock on a network,
and updates itself - this can move the clock forward or backward. Timezone changes can
also impact Date.now(). These are edge-cases, but users do hit them nonetheless.

This patch switches the sampler to use `Cu.now()`, which is a high-resolution interval
from process start to the current time using a monotonic clock.

Differential Revision: https://phabricator.services.mozilla.com/D62760

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Conley 2020-02-13 20:33:56 +00:00
parent e6464dd404
commit a135d65169

View File

@ -1255,7 +1255,7 @@ BrowserGlue.prototype = {
return;
}
let currentTime = Date.now() - Services.startup.getStartupInfo().process;
let currentTime = Math.round(Cu.now());
let averageTime = 0;
let samples = 0;
try {