https://bugzilla.wikimedia.org/show_bug.cgi?id=36731
Web browser: ---
Bug #: 36731
Summary: Cache dir listings to avoid excessive fstat calls
Product: MediaWiki
Version: unspecified
Platform: All
OS/Version: All
Status: UNCONFIRMED
Severity: enhancement
Priority: Unprioritized
Component: ResourceLoader
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected],
[email protected]
Classification: Unclassified
Mobile Platform: ---
I noticed this in config/index.php:getLanguageList()
The current method of opendir/readdir causes an excessive number of fstat
calls. With network based filesystems (glusterfs specifically) this causes a
lot of unnecessary delay.
I propose caching the results of those lookups in session variables to reduce
that impact, for example:
function getLanguageList() {
global $wgLanguageNames, $IP;
if( isset( $_SESSION['getLanguageListcodes'] ) )
return $_SESSION['getLanguageListcodes']
if( !isset( $wgLanguageNames ) ) {
require_once( "$IP/languages/Names.php" );
}
$codes = array();
$d = opendir( "../languages/messages" );
/* In case we are called from the root directory */
if (!$d)
$d = opendir( "languages/messages");
while( false !== ($f = readdir( $d ) ) ) {
$m = array();
if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
$code = str_replace( '_', '-', strtolower( $m[1] ) );
if( isset( $wgLanguageNames[$code] ) ) {
$name = $code . ' - ' .
$wgLanguageNames[$code];
} else {
$name = $code;
}
$codes[$code] = $name;
}
}
closedir( $d );
ksort( $codes );
$_SESSION['getLanguageListcodes'] = $codes
return $codes;
}
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l