From fb192de553b995be48e570b50c6bb90113c6a821 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Mon, 6 Jan 2014 15:18:18 -0800 Subject: [PATCH] Revert Id39d4457a: Remove experiment code for moduleStorage Because of a bug affecting the production cluster during the initial run of the experiment, we need to rerun it. This patch reverts Id39d4457a, restoring the experiment setup code. As before, it will be removed at the conclusion of the experiment. Change-Id: Ifa97d36d3af589ca0586baad2702fb7b58b246e5 --- resources/mediawiki/mediawiki.js | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js index f3bb414703..5623575294 100644 --- a/resources/mediawiki/mediawiki.js +++ b/resources/mediawiki/mediawiki.js @@ -1815,6 +1815,38 @@ var mw = ( function ( $, undefined ) { // Cache hit stats stats: { hits: 0, misses: 0, expired: 0 }, + // Experiment data + experiment: ( function () { + var start = ( new Date() ).getTime(), id = 0, seed = 0; + + try { + id = JSON.parse( localStorage.getItem( 'moduleStorageExperiment2' ) ); + if ( typeof id !== 'number' ) { + id = Math.floor( Math.random() * Math.random() * 1e16 ); + localStorage.setItem( 'moduleStorageExperiment2', id ); + } + seed = id % 2000; + } catch ( e ) {} + + return { + // Unique identifier for this browser. This allows us to group all + // datapoints generated by a particular browser, which in turn allows us + // to see how the initial load compares to subsequent page loads. + id: id, + + // Group assignment may be 0 (not in experiment), 1 (control group), or 2 + // (experimental group). Browsers that don't implement all the prerequisite APIs + // (JSON and Web Storage) are ineligible. Eligible browsers have a 0.1% chance + // of being included in the experiment, in which case they are equally likely to + // be assigned to either the experimental or control group. + group: seed === 1 ? 1 : ( seed === 2 ? 2 : 0 ), + + // Assess module storage performance by measuring the time between this + // reference point and the window load event. + start: start + }; + }() ), + /** * Construct a JSON-serializable object representing the content of the store. * @return {Object} Module store contents. @@ -1875,7 +1907,8 @@ var mw = ( function ( $, undefined ) { return; } - if ( !mw.config.get( 'wgResourceLoaderStorageEnabled' ) || mw.config.get( 'debug' ) ) { + if ( ( !mw.config.get( 'wgResourceLoaderStorageEnabled' ) && mw.loader.store.experiment.group !== 2 ) + || mw.config.get( 'debug' ) ) { // Disabled by configuration, or because debug mode is set mw.loader.store.enabled = false; return; -- 2.20.1