wiki.techinc.nl/includes
Timo Tijhof 268759c154 SiteConfiguration: Optimise getAll() and doReplace() loops
The runtime numbers in each bullet point are based on a local
benchmark that use a copy of WMF's InitialiseSettings.php file
to compute enwiki's $globals via SiteConfiguration::getAll().
Source code and results can be found at
<https://gist.github.com/Krinkle/2ef2fe72218b5f5cea91679df56a0b18>.

* The getSetting() method (called by getAll) was iterating over
  each find/replace pair and performing a separate call to str_replace()
  via doReplace().

  Instead, iterate the pairs only to create a replacements array
  (this array differs from the pairs in that it has a leading "$" in the
  search keys), and then call doReplace() once for each setting value,
  instead of multiple times.

  Also, switch from str_replace() to strtr() while at it (which promises
  to only search the string once, instead of repeatedly until it no
  longer finds any of the search patterns).

  Also also, generate the replacements array outside the getSetting()
  method and do this in the mergeParams() method instead, which is called
  before the getSetting-loop in getArray begins, thus further reducing
  identically repeated work.

  In my local benchmark for WMF/enwiki this reduced runtime from
  ~7.5-8.1ms to ~6.9-7.3ms.

* The getSetting() method was using a by-reference assignment
  for a local variable that would hold a read-only copy a class member
  `$thisSetting =& $this->settings[$settingName];`.

  This was presumably a PHP4 or PHP5 era optimisation to avoid
  an eager memory copy given the promise to only read the data.
  However, in PHP5/PHP7 this is redundant given that PHP
  does copy-on-write.

  Removing the "&" symbol here made a drastic perf improvement,
  reducing my WMF/enwiki benchmark runtime from ~6ms to ~1ms.

Bug: T169821
Change-Id: I0e8b395920c143f2b42f9d87c1afaffa2bfdaf2e
2020-03-03 00:59:51 +00:00
..
actions Replace calls to Title::getUserPermissionsErrors (part 5) 2020-02-26 03:00:33 +00:00
api Localisation updates from https://translatewiki.net. 2020-03-02 08:10:42 +01:00
auth Replace calls to Title::getUserPermissionsErrors (part 5) 2020-02-26 03:00:33 +00:00
block BlockErrorFormatter: Use language-specific comma separators 2020-02-28 11:09:58 +00:00
cache Remove usages of deprecated Language methods 2020-02-16 00:45:48 +00:00
changes Hard deprecate Title::getUserPermissionsErrors 2020-02-26 05:09:55 +00:00
changetags Cleanup various calls to IDatabase::upsert() 2020-02-27 15:27:29 -08:00
clientpool Merge "Use namespaced IPUtils class" 2020-01-01 23:56:22 +00:00
collation Avoid PHP scalar type juggling in includes/ (part 2) 2019-12-30 20:57:18 +00:00
compat Coding style: Auto-fix MediaWiki.Commenting.DocComment.* 2020-01-10 12:28:12 -08:00
composer
config Use namespaced IPUtils class 2020-01-01 02:36:49 -08:00
content Don't use a dynamic hook name when calling a hook 2020-02-25 13:42:30 +11:00
context Remove usages of deprecated Language methods 2020-02-16 00:45:48 +00:00
dao
db rdbms: dependency inject domain aliases into LBFactory 2020-02-15 22:34:38 +00:00
debug profiler: Remove support for $wgDebugLogGroups['profileoutput'] 2020-02-29 18:24:55 +00:00
deferred Move UIDGenerator code to a service and put it under /libs 2020-02-18 00:20:40 +00:00
diff Replace calls to Title::getUserPermissionsErrors (part 5) 2020-02-26 03:00:33 +00:00
edit Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
editpage TextConflictHelper: deprecate old constructor signature 2020-02-12 14:02:38 +11:00
exception Clean up redundant Exception|Throwable union type 2020-02-12 20:28:40 +00:00
export Remove unreachable null checks after isset() 2020-02-28 21:40:48 +00:00
externalstore Upgrade phan to 0.9.1 2020-01-25 10:53:26 +00:00
filebackend Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
filerepo filerepo: Add and fix visibility keywords in ArchivedFile 2020-02-28 16:35:01 +01:00
gallery Replace Linker::link usage with LinkRenderer in includes 2020-01-11 11:20:17 +01:00
historyblob Set visibility on php magic functions __destruct/sleep/wakeup/get/call 2019-12-05 18:52:55 +01:00
htmlform Remove usages of deprecated Language methods 2020-02-16 00:45:48 +00:00
http Update all use of $wgVersion to MW_VERSION 2020-02-25 02:16:12 +00:00
import Introduce ContentHandlerFactory 2020-02-07 00:53:51 +03:00
installer Localisation updates from https://translatewiki.net. 2020-02-27 08:08:19 +01:00
interwiki Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
jobqueue Convert JobRunner into a service and use DI 2020-02-27 08:04:48 -08:00
json FormatJson: Improve parse() error code handling and tests 2020-01-01 02:34:44 -08:00
language Merge "Remove LanguageConverter dependencies on Title and use LinkTarget" 2020-02-12 22:44:12 +00:00
libs rdbms: support native batched replace() in DatabaseSqlite 2020-03-02 15:10:15 +00:00
linkeddata Introduce ContentHandlerFactory 2020-02-07 00:53:51 +03:00
linker Fix @todo asking to document LogPage::getTitleLink() 2020-01-29 13:13:56 +01:00
logging Merge "Hard deprecate LogEventsList::getExcludeClause $wgUser fallback" 2020-02-28 06:50:04 +00:00
mail
media Remove usages of deprecated Language methods 2020-02-16 00:45:48 +00:00
Message Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
Navigation
objectcache objectcache: make ObjectCache::newFromParams() defaults more consistent 2020-03-02 21:07:32 +00:00
page Cleanup various calls to IDatabase::upsert() 2020-02-27 15:27:29 -08:00
pager IndexPager: Limit offset params to the max of the indices available 2020-02-20 13:42:16 -08:00
ParamValidator/TypeDef UserDef: Don't return incomplete UserIdentityValues 2020-02-19 15:28:40 -05:00
parser Remove unreachable null checks after isset() 2020-02-28 21:40:48 +00:00
password Password policy to check if a password is a substring of a username 2020-01-13 23:09:13 +00:00
Permissions Fix the namespace of SpecialPageFactory 2020-02-21 13:46:19 +11:00
poolcounter Set method visibility for various constructors 2019-12-03 20:17:30 +01:00
preferences Special:Preferences: Split the unknown/neutral gender into label and help 2020-02-26 17:22:56 -08:00
profiler Merge "Fix documentation for Tideways XHProf flags" 2020-02-12 22:21:07 +00:00
rcfeed Upgrade phan to 0.9.1 2020-01-25 10:53:26 +00:00
registration Update all use of $wgVersion to MW_VERSION 2020-02-25 02:16:12 +00:00
resourceloader Merge "resourceloader: Add more granular phan type information in various classes" 2020-02-27 21:21:26 +00:00
Rest Localisation updates from https://translatewiki.net. 2020-03-02 08:10:42 +01:00
Revision Merge "Remove unused variables from closure use() lists" 2020-02-29 17:27:01 +00:00
revisiondelete Upgrade phan to 0.9.1 2020-01-25 10:53:26 +00:00
revisionlist Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
search Fix: Add title property to search form 2020-03-02 13:06:33 +00:00
session Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
shell Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull 2020-01-10 14:17:13 -08:00
site Add flag to force local page name normalization in development env 2020-02-18 17:00:20 +01:00
skins skins: Soft deprecate SkinTemplate::getNameSpaceKey() method 2020-03-02 01:52:54 +00:00
sparql Improve param docs 2019-11-28 19:08:59 +01:00
specialpage Hard deprecate all methods of old SpecialPageFactory 2020-02-23 22:07:09 +00:00
specials Merge "SpecialWhatLinksHere: Display section anchor for redirects" 2020-02-27 17:00:31 +00:00
Storage Remove unused variables from closure use() lists 2020-02-29 17:10:28 +00:00
templates Update all use of $wgVersion to MW_VERSION 2020-02-25 02:16:12 +00:00
tidy Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
title Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull 2020-01-10 14:17:13 -08:00
upload Hard deprecate Title::getUserPermissionsErrors 2020-02-26 05:09:55 +00:00
user Remove unused variables from closure use() lists 2020-02-29 17:10:28 +00:00
utils Fix the namespace of SpecialPageFactory 2020-02-21 13:46:19 +11:00
watcheditem When clearing don't load the watchlist if we must clear through a job 2020-01-29 18:36:47 +00:00
widget widgets: Split out SearchWidgets into their own tree 2020-02-11 14:37:27 -08:00
.htaccess
ActorMigration.php ActorMigration: Improve getWhere() handling of $users 2019-12-04 16:00:02 -05:00
AjaxDispatcher.php Set method visibility in some classes 2019-12-05 17:42:55 +00:00
AjaxResponse.php Remove various unused AjaxResponse methods 2020-02-29 17:58:49 -08:00
AutoLoader.php API: Use ParamValidator library 2020-02-04 13:36:14 -05:00
Autopromote.php Use namespaced IPUtils class 2020-01-01 02:36:49 -08:00
BadFileLookup.php
CategoriesRdf.php
Category.php Cleanup various calls to IDatabase::upsert() 2020-02-27 15:27:29 -08:00
CategoryFinder.php Improve param docs 2019-11-28 19:08:59 +01:00
CategoryViewer.php Remove unreachable null checks after isset() 2020-02-28 21:40:48 +00:00
CommentStore.php Remove CommentStore::newKey, deprecated and unused 2020-02-20 02:00:15 +00:00
CommentStoreComment.php
ConfiguredReadOnlyMode.php
ContentSecurityPolicy.php include blob: as a default script-src 2020-02-27 19:02:55 +00:00
DefaultSettings.php Merge "debug: Remove $wgDebugTimestamps feature" 2020-02-28 04:46:40 +00:00
Defines.php Provide MW_VERSION and deprecate fake global $wgVersion 2020-02-25 01:55:21 +00:00
DeprecatedGlobal.php Forbid wfDeprecated with $version = true 2019-12-31 13:53:36 +01:00
DerivativeRequest.php
DevelopmentSettings.php DevelopmentSettings: Enable 'fatal' and 'DeferredUpdates' error channels 2020-02-15 19:18:25 +00:00
DummyLinker.php
EditPage.php Hard deprecate Revision::loadFromTitle 2020-02-28 19:10:17 -08:00
EventRelayerGroup.php
FauxRequest.php Remove IE 6 security features from server-side code 2019-11-28 15:11:56 +11:00
FauxResponse.php Add missing @param and @return to documentation 2019-11-10 22:12:58 +00:00
FeedUtils.php Replace calls to Title::getUserPermissionsErrors (part 5) 2020-02-26 03:00:33 +00:00
FileDeleteForm.php Deprecate calling FileDeleteForm::doDelete without passing a user 2020-02-21 04:11:30 +00:00
ForeignResourceManager.php Improve param docs 2019-11-28 19:08:59 +01:00
ForkController.php Remove usages of $wgMemc 2020-01-20 19:41:32 +01:00
FormOptions.php
GitInfo.php Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull 2020-01-10 14:17:13 -08:00
GlobalFunctions.php profiler: Remove support for $wgDebugLogGroups['profileoutput'] 2020-02-29 18:24:55 +00:00
HeaderCallback.php
Hooks.php Improve param docs 2019-11-28 19:08:59 +01:00
Html.php languages: Introduce LanguageConverterFactory 2020-02-03 11:38:03 +02:00
Linker.php Remove use of global $wgUser in Linker::userToolLinks 2020-02-19 23:39:28 +00:00
LinkFilter.php Use namespaced IPUtils class 2020-01-01 02:36:49 -08:00
ListToggle.php
MagicWord.php Miscellaneous documentation updates 2020-02-16 04:38:38 +00:00
MagicWordArray.php Miscellaneous documentation updates 2020-02-16 04:38:38 +00:00
MagicWordFactory.php Miscellaneous documentation updates 2020-02-16 04:38:38 +00:00
MediaWiki.php Convert JobRunner into a service and use DI 2020-02-27 08:04:48 -08:00
MediaWikiServices.php Convert JobRunner into a service and use DI 2020-02-27 08:04:48 -08:00
MediaWikiVersionFetcher.php MediaWikiVersionFetcher: Change regex to capture any quoted string 2020-02-25 02:16:23 +00:00
MergeHistory.php MergeHistory: Remove use of Title::getUserPermissionsErrors (part 4) 2020-02-18 22:32:21 +00:00
MovePage.php Introduce ContentHandlerFactory 2020-02-07 00:53:51 +03:00
MWGrants.php Remove Language::factory and getParentLanguage use 2019-10-27 12:34:28 +02:00
MWNamespace.php
MWTimestamp.php
NoLocalSettings.php Update all use of $wgVersion to MW_VERSION 2020-02-25 02:16:12 +00:00
OrderedStreamingForkController.php
OutputHandler.php
OutputPage.php Hard deprecate Title::getUserPermissionsErrors 2020-02-26 05:09:55 +00:00
PageProps.php Upgrade phan to 0.9.1 2020-01-25 10:53:26 +00:00
PathRouter.php Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull 2020-01-10 14:17:13 -08:00
PHPVersionCheck.php PHPVersionCheck: Refactor triggerError() to be easier to understand 2020-03-02 01:46:09 +00:00
Pingback.php Cleanup various calls to IDatabase::upsert() 2020-02-27 15:27:29 -08:00
ProtectionForm.php Hard deprecate Title::getUserPermissionsErrors 2020-02-26 05:09:55 +00:00
ProxyLookup.php
RawMessage.php
ReadOnlyMode.php
Revision.php Hard deprecate Revision::countByTitle 2020-02-29 03:24:25 +00:00
ServiceWiring.php Convert JobRunner into a service and use DI 2020-02-27 08:04:48 -08:00
Setup.php Remove wfGetMessageCacheStorage 2020-02-14 20:09:14 +01:00
SiteConfiguration.php SiteConfiguration: Optimise getAll() and doReplace() loops 2020-03-03 00:59:51 +00:00
SiteStats.php Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
SiteStatsInit.php sitestats: cleanup use of upsert() by removing the key column from SET 2020-02-26 01:18:47 -08:00
Status.php Set visibility on php magic functions __destruct/sleep/wakeup/get/call 2019-12-05 18:52:55 +01:00
StreamFile.php Streamline/fix code by using short ?: and ?? syntax 2019-11-11 11:17:13 +01:00
StubObject.php
StubUserLang.php
TemplateParser.php TemplateParser: Make cache value include metadata 2020-03-02 21:21:43 +00:00
TemplatesOnThisPageFormatter.php
Title.php Hard deprecate Title::getUserPermissionsErrors 2020-02-26 05:09:55 +00:00
TitleArray.php Set method visibility in some classes 2019-12-05 17:42:55 +00:00
TitleArrayFromResult.php Set method visibility for various constructors 2019-12-03 20:17:30 +01:00
TitleFactory.php Add TitleFactory 2019-10-18 00:00:46 +02:00
TrackingCategories.php Fix new phan errors, part 3 2019-10-12 10:35:22 +00:00
WebRequest.php Hard deprecate WebRequest::getLimitOffset 2020-02-20 03:02:52 +00:00
WebRequestUpload.php API: Use ParamValidator library 2020-02-04 13:36:14 -05:00
WebResponse.php
WebStart.php docs: Improve "Entry points" documentation page 2020-02-04 21:44:38 +00:00
WikiMap.php Fix more scalar types in docblocks 2019-12-08 17:59:08 +00:00
WikiReference.php
Xml.php Remove usages of deprecated Language methods 2020-02-16 00:45:48 +00:00
XmlJsCode.php Set method visibility for various constructors 2019-12-03 20:17:30 +01:00
XmlSelect.php Set method visibility in some classes 2019-12-05 17:42:55 +00:00