Page MenuHomePhabricator

Fix mediaWikiLoadComplete accuracy
Closed, ResolvedPublic


Right now we measure mwLoadStart in mediawiki-core/startup.js using Date#getTime (same as, but mwLoadEnd using (which uses in modern browsers).

The problem is that using mixing these two approaches produces inaccurate results.

For example:

now = ( function () { var perf = window.performance, navStart = perf && perf.timing && perf.timing.navigationStart; return navStart && typeof === 'function' ? function () { return navStart +; } : function () { return +new Date(); }; }() );
a = { d:, p: now() }; b = { d:, p: now() };
[a, b]
> Array(2)
> 0: Object
> - d: 1482298290210
> - p: 1482298290232.265
> 1: Object
> - d: 1482298290210
> - p: 1482298290232.27

It seems they are consistently off by the same amount within a single tab. In the above example, was consistently 22ms later than - which would cause things to appear 22ms slower than they really are (assuming end-start; where is used for start, and for end).

Browsing other random pages on various domains I get offsets varying from -1 to -90ms. And, at least in Google Chrome, the offset always gets worse as more time goes by (one is ticking faster than the other).

We should account for this offset or work around it.

Proposed solutions:

  1. Move definition to startup.js and use it there for mwLoadStart (e.g. define as mwNow and assign to later).
  2. Or; Compute difference between and and subtract it when computing mwLoadEnd and mediaWikiLoadComplete in ext.navigationTiming.js

Event Timeline

Krinkle triaged this task as Medium priority.

Change 336913 had a related patch set uploaded (by Krinkle):
resourceloader: Use for mediaWikiLoadStart in startup.js

Change 336913 merged by jenkins-bot:
resourceloader: Use for mediaWikiLoadStart in startup.js

Keeping this open until the end of the week to see if we observe any notable changes in the metric measures.

No significant impact on graphs for mediaWikiLoadComplete. Compared with timeShift(-7d) and movingAverage(30min). 1.29.0-wmf.12 was deployed to all wikis between 7PM and 10PM on Thursday, 16 February.


  • median, overal: Unaffected (~920ms)


  • median, overall: Unaffected (~850ms)
  • p75, desktop, anonymous: Unaffected (~ 1.1s)
  • p95, desktop, anonymous: Unaffected (~ 4.0s)
  • p75, mobile, anonymous: 0.1s faster (before: 2.1-2.3s; after: 1.9-2.2s)
  • p95, mobile, anonymous: Unaffected (~ 4.9s - 6.5s)