aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/benchmarks
Commit message (Collapse)AuthorAgeFilesLines
* maintenance: Use type declaration on undocumented private functionsUmherirrender2025-03-313-3/+3
| | | | Change-Id: I2c1bc3b4e0ee782076ddaeae133672b730d345d9
* Replace a number of uses of class aliases with the real thingsJames D. Forrester2025-03-2612-2/+19
| | | | | | | Found via disabling phan's alias support for a run (and ignoring wgLang's hard-coded state of being a \Language, alas). Change-Id: I4753bcd84d72d6de111fc7ffc5841fa417bf7333
* Split MediaWikiTitleCodecTim Starling2025-03-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | For the linked bug, I would really like GenderCache to use UserOptionsManager. But all user-related services need UserNameUtils which depends on TitleParser, and TitleFormatter needs GenderCache to correctly format NS_USER titles. Having TitleFormatter and TitleParser together in a single class creates an intractable dependency loop. So, split MediaWikiTitleCodec. On Daniel's advice I converted the existing TitleParser and TitleFormatter interfaces to classes. The code was always structured to allow this. Extensions require surprisingly few updates. MediaWikiTitleCodec remains only for its deprecated static methods. The implementations were split cleanly with no need for shared code. The tests did have a little bit of shared code, for round-trip testing, so I added a shared test base class for that. Bug: T386584 Depends-On: Ibf307e953b666d8923bc96a507907421558da378 Depends-On: I47e83e95727e6830500e9af7cff92e7d3f91167e Depends-On: Id9c045864a9dc3c640a896e6b34f516c7e42b050 Change-Id: I3dcce6639ed01c7611a663671c872cec775bdaa2
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-171-2/+0
| | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* maintenance: Use namespaced classesUmherirrender2024-10-211-0/+1
| | | | | | | This does not include use of MediaWiki\Maintenance\Maintenance, assuming the maintenance scripts going into the same namespace Change-Id: I488f95b537ce86eb5e463be7bce3653610dd13d9
* maintenance: Use more of namespaced Maintenance classReedy2024-10-161-0/+1
| | | | Change-Id: I53f2e32c73c92cc3a0deee48ebe6d13329a7a0cf
* Pass function name to IDatabase functionsUmherirrender2024-09-191-2/+2
| | | | Change-Id: Ie2a1e5052e5b61bbb5b89905de942f47d3f1413d
* maintenance: Add missing documentation to class propertiesUmherirrender2024-09-135-0/+5
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: I7dec01892a987a87b1b79374a1c28f97d055e8fa
* Exclude boilerplate maintenance code from code coverage reportsDreamy Jazz2024-08-2713-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * Maintenance scripts in core have bolierplate code that is added before and after the class to allow directly running the maintenance script. * Running the maintenance script directly has been deprecated since 1.40, so this boilerplate code is only to support a now deprecated method of running maintenance scripts. * This code cannot also be marked as covered, due to PHPUnit not recognising code coverage for files. * Therefore, it is best to ignore this boilerplate code in code coverage reports as it cannot be marked as covered and also is for deprecated code. What: * Wrap the boilerplate code (requiring Maintenance.php and then later defining the maintenance script class and running if the maintenance script was called directly) with @codeCoverageIgnore comments. * Some files use a different boilerplate code, however, these should also be marked as ignored for coverage for the same reason that coverage is not properly reported for files. Bug: T371167 Change-Id: I32f5c6362dfb354149a48ce9c28da9a7fc494f7c
* Add MediaWiki\Registration namespace to registration classesEbrahim Byagowi2024-08-101-0/+1
| | | | | Bug: T353458 Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-0/+2
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* Rename JsonUnserial… to JsonDeserial…James D. Forrester2024-06-121-2/+2
| | | | | | | | This is to make it clearer that they're related to converting serialized content back into JSON, rather than stating that things are not representable in JSON. Change-Id: Ic440ac2d05b5ac238a1c0e4821d3f2d858bc3d76
* Namespace includes/cacheJames D. Forrester2024-02-201-0/+1
| | | | | Bug: T353458 Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
* Merge "maintenance: Introduce getReplicaDB() and getPrimaryDB()"jenkins-bot2024-01-201-1/+1
|\
| * maintenance: Introduce getReplicaDB() and getPrimaryDB()Amir Sarabadani2024-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | And start using them instead of wfGetDB(), LB/LBF connection methods or worse, $this->getDB(). $this->getDB() reuses the database object regardless of whether you're calling a replica or primary, leading to returning a replica on a primary and other way around. Bug: T330641 Change-Id: I9e2cf85ca277022284fc26b9f37db57bd12aaa81
* | ResourceLoader: Remove libs/jsminplus.php (JSMinPlus, JSParser)Timo Tijhof2024-01-191-11/+0
|/ | | | | | | No longer used. Bug: T75714 Change-Id: I2b097671716fabec169bc803da98cd0340d70cc4
* maintenance: Migrate to expression buildersAmir Sarabadani2024-01-171-1/+1
| | | | | | | This was somehow left out Bug: T210206 Change-Id: I70851b5b99fa865dbfd629caf2c1866c85418350
* ResourceLoader: Switch validateScriptFile() from JSMinPlus to PeastTimo Tijhof2024-01-061-0/+9
| | | | | | | | | | This adds support for ES6 and ES7 syntax to user scripts, thus matching the wikimedia/minify library. Bug: T75714 Depends-On: I43d4619a32e37eb42e1aaa55a1f602962609c52b Depends-On: If3b2b4a75013baeaa0d9b92cd10dfb06e5534153 Change-Id: Ie309e761f8b20640f7c0e85def0a3d1ccc8a658e
* Merge "Replace use of "unquoted" with "raw" for tableName() callers"jenkins-bot2023-11-231-4/+4
|\
| * Replace use of "unquoted" with "raw" for tableName() callersAaron Schulz2023-11-211-4/+4
| | | | | | | | Change-Id: I4fed3a901ef212b1f502e7f90ecd6cf3dc1295f0
* | Namespace remaining files under includes/deferredJames D. Forrester2023-11-221-0/+2
|/ | | | | Bug: T166010 Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
* Replace deprecated Linker::formatComment in benchmarkCommentFormatterFomafix2023-10-131-5/+5
| | | | Change-Id: I3ff75fc9e78217324c737a4fb677bea68c569387
* Maintenance: use getServiceContainer() methoddaniel2023-10-131-5/+4
| | | | | | | Use getServiceContainer instead of calling MediaWikiServices::getInstance(). Change-Id: I3901ef866963d33649f8fa170ad6fbc7ca81f0fb
* ResourceLoader: Improve and generalize validateScriptFile test coverageTimo Tijhof2023-10-021-5/+8
| | | | | | | | | | | | | | | | In preparation for the underlying library changing, generalize the tests for this code so that test changes are kept to a minimum in the actual commit. Rather than test the upstream directly, move our custom test cases from JsMinPlusTest to ResourceLoader/ModuleTest. Fix benchmarkJSMinPlus.php to not emit warnings on PHP 8.2 due to use of dynamic property creation: > PHP Deprecated: Creation of dynamic property JSNode::$readOnly > is deprecated in /mediawiki/includes/libs/jsminplus.php:1728 Bug: T75714 Change-Id: I0515be8229f51de48c1f0c92f09e2d827e1b1add
* Namespace Sanitizer under \MediaWiki\ParserJames D. Forrester2023-09-211-0/+1
| | | | | Bug: T166010 Change-Id: Id13dcbf7a0372017495958dbc4f601f40c122508
* Namespace TitleParser under \MediaWiki\TitleJames D. Forrester2023-09-191-0/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: I4848e903b0c0a2f7c58ac19e0baeef0085a36bdc
* Namespace TitleFormatter under \MediaWiki\TitleJames D. Forrester2023-09-191-0/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
* Namespace TitleValue under \MediaWiki\TitleJames D. Forrester2023-09-181-0/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
* maintenance: Begin using `Maintenance::getServiceContainer()`Derick Alangi2023-09-043-11/+7
| | | | | | | | | | | Maintenance class provides a method for getting a fresh reference of the MW services container instance. Let's make use of these in maintenance scripts now that we have it. NOTE: There are still some static methods like in refreshLinks.php that makes use of services that we can't use this method for now. Change-Id: Idba744057577896fc97c9ecf4724db27542bf01c
* Migrate more calls of Database::select* to SelectQueryBuilderAmir Sarabadani2023-07-261-12/+9
| | | | | | | | | Using a php parser written on top of ANTLR4, done semi-automatically. I checked everything and made adjustments. Bug: T311866 Change-Id: I6150c6909bce8f3dbd745a26380cc0af9d9c547f
* Replace deprecated Hooks::register in benchmarkParse.phpUmherirrender2023-05-181-1/+2
| | | | Change-Id: Id68d2f0731f9d3aae934e7fe7d5f602fd71ea1ec
* Update benchmarkHooks.php to use HookContainerTim Starling2023-05-181-6/+5
| | | | | | | benchmarkHooks.php just gave a fatal error. So update it to use HookContainer::register() and HookContainer::run(). Change-Id: Ifa1fe5a39d70f6779c002815be19e46ad81f6dc6
* Fix Phan suppressions related to Title::castFrom*() and friendsBartosz Dziewoński2023-04-221-1/+1
| | | | | | | | | | | | | | | | | | | | | There is no way to express that Title::castFromPageIdentity(), Title::castFromPageReference() and Title::castFromLinkTarget() can only return null when the parameter is null. We need to add Phan suppressions or explicit types almost everywhere that these methods are used with parameters that are known to not be null. Instead, introduce new methods Title::newFromPageIdentity() and Title::newFromPageReference() (Title::newFromLinkTarget() already exists), without the null-coalescing behavior, and use them when the parameter is not null. This lets static analysis tools, and humans, easily understand where nulls can't appear. Do the same with the corresponding TitleFactory methods. Change the obvious uses of castFrom*() to newFrom*() (if there is a Phan suppression, a type check, or a method call on the result). Change-Id: Ida4da75953cf3bca372a40dc88022443109ca0cb
* build: Cleanup of .phpcs.xmlUmherirrender2023-04-131-0/+2
| | | | | | Use inline suppression for known exception from eval/passthru/query call Change-Id: Ie85ea5698a615adf07e4e391bf06d102149effd5
* Merge "Reorg: Namespace the Title class"jenkins-bot2023-03-023-0/+3
|\
| * Reorg: Namespace the Title classJames D. Forrester2023-03-023-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* | Remove support for MW_USE_LEGACY_DEFAULT_SETTINGSdaniel2023-03-021-17/+0
|/ | | | | | | | | | | | | | | The purpose of MW_USE_LEGACY_DEFAULT_SETTINGS was to allow Setup.php to load default values from DefaultSettings.php, instead of using MainConfigSchema. It was put into place for the benefit of third-party installations that encounter issues with using MainConfigSchema. No such issues have been reported, so we can remove the compatibility switch in 1.40. The use of DefaultSettings.php as been deprecated since 1.39, but there are still several extensions that rely on loading it. It remains a stub for MainConfigSchema::listDefaultValues() for now. Change-Id: I280f80e5be15fbcd809596087b299add5f83af1f
* benchmarks: Add --setup to benchmarkEval.phpTimo Tijhof2023-01-031-1/+9
| | | | | | | | | | | | | | | | | | | | | | Allows ad-hoc defining of a function that is then invoked with some additional context from the code snippet. Using the example from <https://wikitech.wikimedia.org/wiki/Performance/Guides/PHP_optimisation_tips> ``` $ php maintenance/benchmarks/benchmarkEval.php \ --setup 'function getFirstElement($array) { return reset( $array ); }' \ --code '$array = range(0, 1000000); getFirstElement($array);' $ php maintenance/benchmarks/benchmarkEval.php \ --setup 'function getFirstElement($array) { return $array[0]; }' \ --code '$array = range(0, 1000000); getFirstElement($array);' ``` This behaves notably different from e.g. placing a `return reset()` directly in the eval code body, presumably due to lack of function indirection. Change-Id: I024b44504d94786caa64a2ad7d4558aa755af984
* Merge "SettingsBuilder: introduce a "registration" stage"jenkins-bot2022-12-191-1/+1
|\
| * SettingsBuilder: introduce a "registration" stagedaniel2022-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, SettingsBuilder would allow configuration to be loaded and modified until it was "finalized", at which point configuration became read only. This patch introduces an intermediate stage where registration dynamic manipulation of config values can be performed, after all extensions have been loaded and all config schemas are known. Motivation: Extension registration callbacks are typically used to dynamically set config variables, often based on other configuration. This should be done using SettingsBuilder rather than global variables. But previously, we could only be sure that all extensions are known after SettingsBuilder was "finalized", at which point it would be impossible to change config values. Change-Id: I6f8f9f3f7252f0024282d7b005671f28a5b3acc3
* | Reorg: Move DummyLinker and Linker to linker/Amir Sarabadani2022-12-081-0/+1
|/ | | | | | | This feels like a no-brainer unless I'm missing something obvious Bug: T321882 Change-Id: Id49c3d0dd6ea4593211048850856b5b8e05a8fb3
* benchmarks: Add benchmark for JsonCodecdaniel2022-10-111-0/+96
| | | | Change-Id: Ib3d5d7cea3e0920b4f10bef117dda1de2238e391
* Move dynamic defaults into MainConfigSchemaAryeh Gregor2022-07-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The goal is to keep the actual default values for settings in the same place as the setting is declared, and applied using the regular means for loading the settings -- not in a separate piece of code that needs to be loaded through some entirely different mechanism. SetupDynamicConfig.php now contains a few categories of things: * Post-processing of configuration settings, where already-set settings are altered. This could be moved to MainConfigSchema too as a separate set of methods. * Processing of old aliases of settings (blacklist, slave) that are not registered as settings anymore and therefore are not available to MainConfigSchema. This could perhaps be moved to LocalSettings processing somehow? * Setting $wgUseEnotif, which is also not registered as a setting. Easiest would be just to declare it as a setting and have it set unconditionally. * Setting the actual timezone to $wgLocaltimezone. This is not related to configuration and should just be in Setup.php. Bug: T305093 Change-Id: Ia5c23b52dbbfcb3d07ffcf5d3b7f2d7befba2a26
* Add benchmarks for applying dynamic config.daniel2022-05-091-0/+25
| | | | | Bug: T305093 Change-Id: I7f4d6b2f2a4be01e5e5a65f94b7d91565e417b4b
* Config builder optimisations (combined)Tim Starling2022-05-061-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a modified rebase of a patch by Tim, see I75f405930a7b14561389c59d147640e870146bec. Some benchmark results (from my laptop): Loading defaults from config-schema.php: - Master: 115/sec ( 8.7ms) - I75f4059: (Tim): 575/sec ( 1.7ms) - Id9dd0bf: (Daniel): 1120/sec ( 0.9ms) - This (Tim+Daniel): 1420/sec ( 0.7ms) Loading defaults and merging settings (worst case): - Master: 80/sec (12.4ms) - I75f4059: (Tim): 93/sec (10.8ms) - Id9dd0bf: (Daniel): 200/sec ( 4.9ms) - This (Tim+Daniel): 682/sec ( 1.5ms) Original commit message by Tim: * Explicitly import function array_key_exists to activate the special opcode * Batch creation of MergeStrategy objects * Batch default assignment to ArrayConfigBuilder The batches mostly help by allowing more inlining, eliminating some function calls. Reduced time for apply/finalize benchmark from 540µs to 170µs. Co-Authored-By: Tim Starling <tstarling@wikimedia.org> Change-Id: I3d4dd685eaaa4351801b3bac6ce1592eea925c5f
* Use MainConfigNames instead of string literals, #5Aryeh Gregor2022-04-271-3/+6
| | | | | | | This should be the last of the usages in core, although I'm sure a few are hiding somehow. Change-Id: I7bf0b24bf23d3efb4c56a891830bbfe67945e899
* Benchmark script for settings loading.daniel2022-03-311-0/+105
| | | | Change-Id: I323a3469c574b55ad78abb35863f30b1007f3135
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-212-0/+5
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* Merge "Hard deprecate Sanitizer::removeHTMLtags()"jenkins-bot2022-03-081-9/+11
|\
| * Hard deprecate Sanitizer::removeHTMLtags()C. Scott Ananian2022-03-071-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename Sanitizer::removeHTMLtags() into an @internal method named ::internalRemoveHtmlTags() so that we can deprecate external use. Code search: https://codesearch.wmcloud.org/deployed/?q=removeHTMLtags&i=nope&files=&excludeFiles=&repos= Followup-To: Ic864c01471c292f11799c4fbdac4d7d30b8bc50f Depends-On: Iaca83ed06e9c61d8366579cd2283cba653c82319 Depends-On: I1963bfe9a99198ea02ca482a5769467ce806cd58 Depends-On: I83923d8b38d33f3638cd53958dd10f257ec21f7c Depends-On: I018b34bb5f6e113056da9b04cc72d4318422adce Change-Id: I202826f8b27519f7be89643e24eda47a6e3fc9f6