Event Timeline
Effective settings of enwiki, as generated by CommonSettings.php, with only slight trickery. InterwikiCache is omitted. Only using info from public repos, garnished with a fake PrivateSettings file.
Some parts of this are specific to the data center or server group. This is for page views on eqiad.
I put this in my LocalSettings to grab this snapshot:
$commonSettingsDir = __DIR__ . '/mnt/wmf-config/wmf-config'; if ( file_exists( $commonSettingsDir ) ) { define( 'MEDIAWIKI_STAGING_DIR', __DIR__ . '/mnt/srv/mediawiki-staging' ); define( 'MEDIAWIKI_DEPLOYMENT_DIR', __DIR__ . '/mnt/srv/mediawiki' ); define( 'WMF_NO_ETCD', 1 ); define( 'MW_NO_EXTENSION_MESSAGES', 1 ); $mockWmgClusterFile = __DIR__ . '/mnt/srv/wikimedia-cluster'; require_once $commonSettingsDir . '/../multiversion/MWConfigCacheGenerator.php'; MWMultiVersion::initializeForWiki( 'en.wikipedia.org' ); $wmfDatacenter = 'eqiad'; $wmfMasterDatacenter = 'eqiad'; $wmfConfigDir = $commonSettingsDir; $wmfRealm = 'production'; require_once "$commonSettingsDir/CommonSettings.php"; } if ( isset( $wgServer ) ) { $settings = []; foreach ( $GLOBALS as $name => $value ) { if ( str_starts_with( $name, 'wg' ) && !is_object( $value ) ) { $name = substr( $name, 2 ); if ( $name === 'Hooks' || $name === 'ExtensionFunctions' || $name === 'AutoloadLocalClasses' ) { continue; } if ( $name === 'InterwikiCache' ) { continue; } if ( $name === 'MWLoggerDefaultSpi' ) { $value = 'FIXME: factory callback'; } if ( $name === 'WBClientSettings' ) { $value = 'FIXME: lazy initialization callnacks'; } if ( is_float( $value ) && !is_finite( $value ) ) { if ( is_nan( $value ) ) { $value = '!php/const NAN'; } if ( is_infinite( $value ) ) { $value = $value > 0 ? '!php/const NAN' : '!php/const -NAN'; } } $settings[ $name ] = $value; } } ksort( $settings ); $codec = new JsonCodec(); $badPath = $codec->detectNonSerializableData( $settings ); if ($badPath) { die( 'NOPE: ' . $badPath ); } $json = FormatJson::encode( $settings, true, FormatJson::ALL_OK ); file_put_contents( __DIR__ . '/cache/settings.json', $json ); die( 'YAY!' ); }
Timing results:
Loading the JSON file is x30 faster than executing CommonSettings.php: On my system, without debugger, CommonSettings.php hovers around 30ms, while loading JSON is around 1ms.
Turns out json_decode craps out and returns JSON_ERROR_SYNTAX for no good reason. Both json_pp and jsonlin-php think it's fine. Annoying.
For the test, InitializeSettings was already read from JSON via MWConfigCacheGenerator, and InterwikiCache was included in the final JSON that was then read back.
I managed to read the JSON back in php afterall. Takes about 10ms on my system, without debugger. So that's a x3 speedup.