gecko-dev/dom/performance
Tom Ritter d0170278b3 Bug 1429764 Do not call ReduceTimerPrecision twice for DOM Navigation timers r=bkelly,timhuang
Bug 1429764 details a test failure that was asserting that the performance navigation
timers were strictly increasing (or equal). fetchStart should have a timestamp before
domainLookupStart.  But it didn't.

The problem is two-fold.  This corrects the test and the issue by addressing one part
of the problem, the second part of the problem needs to be written up in a new bug
and addressed there. (That bug is not yet filed at writing, but see dependencies of
1429764 in the future to find it.)

The second, and underlying, problem is that calling ReduceTimerPrecision with the
same value multiple times may continually reduce it. Meaning that the first you call
it with, say, .75, (and a precision of .20), it will be reduced to .6. The second time
you call it (with .6), instead of staying at .6 it will be reduced to .4. This is
because floats are fuzzy. Inside ReduceTimerPrecision we are multiplying a decimal by
a decimal, so while floor(.6 / .20)  should equal 3, sometimes it's actually 2.999...
which gets floors to 2, gets multiplied again by .2, and which results in .4

If that's the underlying problem, the first, and surface, problem is - why are we
calling ReduceTimerPrecision multiple times? We shouldn't be. That's what this
patch fixes.

TimeStampToDOMHighResOrFetchStart will return either TimeStampToDOMHighRes() or
FetchStartHighRes(). FetchStartHighRes() internally calls TimeStampToDOMHighRes
and then ReduceTimerPrecision - this is where (some of) the two reduction calls
happen - because TimeStampToDOMHighRes itself calls ReduceTimerPrecision also.

I remove the ReduceTimerPrecision from TimeStampToDOMHighRes. FetchStartHighRes
will now only call ReduceTimerPrecision once, at the end of the return.

But we have to fix places we call TimeStampToDOMHighResOrFetchStart, because the
callers of that function also call ReduceTimerPrecision. So if
TimeStampToDOMHighResOrFetchStart returned FetchStartHighRes, we'd be calling
ReduceTimerPrecision twice for those callers.

So inside first off, we remove the outer call to ReduceTimerPrecision. that
surrounds the 5 or so callsites of TimeStampToDOMHighResOrFetchStart. Then
inside of TimeStampToDOMHighResOrFetchStart we return either FetchStartHighRes
(which is has already called ReduceTimerPrecision) or we call
ReduceTimerPrecision with the value.

Now. TimeStampToDOMHighRes was used in more places than just FetchStartHighRes -
there were several other places where we were doing double rounding, and this
fixed those as well. AsyncOpenHighRes, WorkerStartHighRes, DomainLookupEndHighRes,
ConnectStartHighRes, SecureConnectionStartHighRes, ConnectEndHighRes, and
ResponseEndHighRes.

MozReview-Commit-ID: K5nHql135rb

--HG--
extra : rebase_source : e06785203f0f8b01fc7b694ce840f07dc09bc4a1
2018-01-12 13:36:04 -06:00
..
tests Bug 1417431 - secureConnectionStart should be 0 for pages with HTTP scheme. r=bkelly 2017-12-06 12:57:28 +01:00
Performance.cpp Bug 1424341 Round the Performance Timing APIs when privacy.reduceTimerPrecision is set r=bkelly,timhuang 2018-01-10 15:51:23 -06:00
Performance.h Backed out changeset 6827b7bf9116 (bug 1263722) for leaks detected on mochitest shutdown. r=backout 2017-09-25 09:57:13 +02:00
PerformanceEntry.cpp Bug 1403178 - Remove mParent assertion from Performance* as it's triggered in headless mode r=baku 2017-09-28 08:26:11 +02:00
PerformanceEntry.h Bug 1403178 - Remove mParent assertion from Performance* as it's triggered in headless mode r=baku 2017-09-28 08:26:11 +02:00
PerformanceMainThread.cpp Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 5 - Performance logging enabled, r=asuth 2018-01-08 14:05:04 +01:00
PerformanceMainThread.h Backed out changeset 6827b7bf9116 (bug 1263722) for leaks detected on mochitest shutdown. r=backout 2017-09-25 09:57:13 +02:00
PerformanceMark.cpp Bug 1403178 - Remove mParent assertion from Performance* as it's triggered in headless mode r=baku 2017-09-28 08:26:11 +02:00
PerformanceMark.h Bug 1382768 - Performance API must be a memory reporter, r=bz 2017-07-27 09:05:51 +02:00
PerformanceMeasure.cpp Bug 1403178 - Remove mParent assertion from Performance* as it's triggered in headless mode r=baku 2017-09-28 08:26:11 +02:00
PerformanceMeasure.h Bug 1382768 - Performance API must be a memory reporter, r=bz 2017-07-27 09:05:51 +02:00
PerformanceNavigation.cpp Bug 1278838 - Remove separate worker binding for Performance API, r=smaug 2016-06-09 19:04:42 +02:00
PerformanceNavigation.h Bug 1279194 - Get rid of nsDOMPerformanceNavigationType, r=smaug 2016-06-10 16:29:46 +02:00
PerformanceNavigationTiming.cpp Bug 1403926 - Make sure PerformanceNavigationTiming timestamps are correct r=baku 2017-10-04 04:05:39 +02:00
PerformanceNavigationTiming.h Bug 1424341 Round the Performance Timing APIs when privacy.reduceTimerPrecision is set r=bkelly,timhuang 2018-01-10 15:51:23 -06:00
PerformanceObserver.cpp Bug 1419597 - Part 18: Remove IsInnerWindow and IsOuterWindow methods, r=smaug 2017-11-23 13:12:13 -05:00
PerformanceObserver.h Backed out changeset c2c746884242 (bug 1403027) for failing M-e10s(2,h2) without failure summary on Windows. r=backout on a CLOSED TREE 2017-10-25 23:44:40 +02:00
PerformanceObserverEntryList.cpp Bug 1396228 - Filter out by type if the type if specified for PerformanceEntry.getEntries. r=baku 2017-09-02 21:42:00 +09:00
PerformanceObserverEntryList.h
PerformanceResourceTiming.cpp Bug 1191943 P1 Implement PerformanceResourceTiming.workerStart. r=asuth 2017-10-06 09:04:54 -07:00
PerformanceResourceTiming.h Bug 1415740 P1 Allow PerformanceResourceTiming.workerStart to be accessed on no-cors resources without Timing-Allow-Origin. r=baku 2017-11-10 00:20:30 -08:00
PerformanceService.cpp Bug 1313420 - Implement Performance.timeOrigin - part 1, r=bz 2016-11-17 10:00:05 +01:00
PerformanceService.h Bug 1313420 - Implement Performance.timeOrigin - part 1, r=bz 2016-11-17 10:00:05 +01:00
PerformanceTiming.cpp Bug 1429764 Do not call ReduceTimerPrecision twice for DOM Navigation timers r=bkelly,timhuang 2018-01-12 13:36:04 -06:00
PerformanceTiming.h Bug 1429764 Do not call ReduceTimerPrecision twice for DOM Navigation timers r=bkelly,timhuang 2018-01-12 13:36:04 -06:00
PerformanceWorker.cpp Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 5 - Performance logging enabled, r=asuth 2018-01-08 14:05:04 +01:00
PerformanceWorker.h Bug 1159003 - Remove Performance::GetAsISupports(), r=bz 2017-07-20 19:05:38 +02:00
moz.build Backed out changeset 6827b7bf9116 (bug 1263722) for leaks detected on mochitest shutdown. r=backout 2017-09-25 09:57:13 +02:00