Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/95129
Change subject: Controlled experiment to assess performance of module storage ...................................................................... Controlled experiment to assess performance of module storage Accompanies Id2835eca4. Logs module load timing data from browsers that are in the experiment or control group. See <https://meta.wikimedia.org/wiki/Schema:ModuleStorage>. Change-Id: Ib9f4a56153066741bdae352910433e214ebcb621 --- M WikimediaEvents.php A modules/ext.wikimediaEvents.moduleStorage.js 2 files changed, 83 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents refs/changes/29/95129/1 diff --git a/WikimediaEvents.php b/WikimediaEvents.php index 48c3f9d..97de9bc 100644 --- a/WikimediaEvents.php +++ b/WikimediaEvents.php @@ -42,8 +42,19 @@ 'schema' => 'VisualEditorDOMSaved', 'revision' => 6063754, ), + 'schema.ModuleStorage' => array( + 'class' => 'ResourceLoaderSchemaModule', + 'schema' => 'ModuleStorage', + 'revision' => 6345184, + ), 'ext.wikimediaEvents.ve' => array( 'scripts' => 'ext.wikimediaEvents.ve.js', + 'localBasePath' => __DIR__ . '/modules', + 'remoteExtPath' => 'WikimediaEvents/modules', + ), + 'ext.wikimediaEvents.moduleStorage' => array( + 'scripts' => 'ext.wikimediaEvents.moduleStorage.js', + 'dependencies' => array( 'mediawiki.inspect', 'schema.ModuleStorage' ), 'localBasePath' => __DIR__ . '/modules', 'remoteExtPath' => 'WikimediaEvents/modules', ), @@ -52,7 +63,14 @@ // Hooks $wgHooks[ 'BeforePageDisplay' ][] = function ( &$out, &$skin ) { + global $wgResourceLoaderStorageEnabled; + $out->addModules( 'ext.wikimediaEvents.ve' ); + + if ( !$wgResourceLoaderStorageEnabled ) { + $out->addModules( array( 'schema.ModuleStorage', 'mediawiki.inspect', 'ext.wikimediaEvents.moduleStorage' ) ); + } + return true; }; diff --git a/modules/ext.wikimediaEvents.moduleStorage.js b/modules/ext.wikimediaEvents.moduleStorage.js new file mode 100644 index 0000000..93d14c7 --- /dev/null +++ b/modules/ext.wikimediaEvents.moduleStorage.js @@ -0,0 +1,65 @@ +/** + * Track VisualEditor events. + * @see https://meta.wikimedia.org/wiki/Schema:ModuleStorage + */ +( function ( mw, $ ) { + + if ( + // Return early + // ..if we're in debug mode. + mw.config.get( 'debug' ) || + // ..if module storage is enabled by default. + mw.config.get( 'wgResourceLoaderStorageEnabled' ) || + // ..if the user is not included in the experiment. + ( mw.loader.store.experimentGroup !== 1 && mw.loader.store.experimentGroup !== 2 ) + ) { + return; + } + + function getExperimentHash() { + var hash; + try { + hash = localStorage.getItem( 'moduleStorageHash' ); + if ( typeof hash !== 'string' ) { + hash = mw.user.generateRandomSessionId(); + localStorage.setItem( 'moduleStorageHash', hash ); + } + } catch ( e ) {} + return hash; + } + + $( window ).load( function () { + var store, moduleLoadingTime, event; + + store = mw.loader.store; + moduleLoadingTime = ( new Date() ).getTime() - store.experimentStart; + + event = { + experimentGroup: store.experimentGroup, + experimentHash: getExperimentHash(), + moduleLoadingTime: moduleLoadingTime, + moduleStoreEnabled: store.enabled, + userAgent: navigator.userAgent, + loadedModulesCount: 0, + loadedModulesSize: 0 + }; + + $.each( mw.inspect.getLoadedModules(), function ( i, module ) { + event.loadedModulesCount++; + event.loadedModulesSize += mw.inspect.getModuleSize( module ); + } ); + + if ( store.enabled ) { + event.moduleStoreExpired = store.stats.expired; + event.moduleStoreHits = store.stats.hits; + event.moduleStoreMisses = store.stats.misses; + } + + if ( mw.mobileFrontend && mw.config.exists( 'wgMFMode' ) ) { + event.mobileMode = mw.config.get( 'wgMFMode' ); + } + + mw.eventLog.logEvent( 'ModuleStorage', event ); + } ); + +}( mediaWiki, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/95129 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib9f4a56153066741bdae352910433e214ebcb621 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikimediaEvents Gerrit-Branch: master Gerrit-Owner: Ori.livneh <o...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits