jenkins-bot has submitted this change and it was merged.

Change subject: benchmarkParse: Add option to clear link cache
......................................................................


benchmarkParse: Add option to clear link cache

For performance testing the lookup of links (e.g. LinkHolderArray),
allow resetting the LinkCache after every parse.

Change-Id: I75c2cad9a8cf1b41d192708773194f799673ce83
---
M maintenance/benchmarks/benchmarkParse.php
1 file changed, 18 insertions(+), 0 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/maintenance/benchmarks/benchmarkParse.php 
b/maintenance/benchmarks/benchmarkParse.php
index 884e307..1753250 100644
--- a/maintenance/benchmarks/benchmarkParse.php
+++ b/maintenance/benchmarks/benchmarkParse.php
@@ -24,6 +24,8 @@
 
 require __DIR__ . '/../Maintenance.php';
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Maintenance script to benchmark how long it takes to parse a given title at 
an optionally
  * specified timestamp
@@ -33,6 +35,13 @@
 class BenchmarkParse extends Maintenance {
        /** @var string MediaWiki concatenated string timestamp 
(YYYYMMDDHHMMSS) */
        private $templateTimestamp = null;
+
+       private $clearLinkCache = false;
+
+       /**
+        * @var LinkCache
+        */
+       private $linkCache;
 
        /** @var array Cache that maps a Title DB key to revision ID for the 
requested timestamp */
        private $idCache = [];
@@ -52,6 +61,8 @@
                        'Use templates which were current at the given time 
(except that moves and ' .
                        'deletes are not handled properly)',
                        false, true );
+               $this->addOption( 'reset-linkcache', 'Reset the LinkCache after 
every parse.',
+                       false, false );
        }
 
        function execute() {
@@ -59,6 +70,10 @@
                        $this->templateTimestamp = wfTimestamp( TS_MW, 
strtotime( $this->getOption( 'tpl-time' ) ) );
                        Hooks::register( 'BeforeParserFetchTemplateAndtitle', [ 
$this, 'onFetchTemplate' ] );
                }
+
+               $this->clearLinkCache = $this->hasOption( 'reset-linkcache' );
+               // Set as a member variable to avoid function calls when we're 
timing the parse
+               $this->linkCache = 
MediaWikiServices::getInstance()->getLinkCache();
 
                $title = Title::newFromText( $this->getArg() );
                if ( !$title ) {
@@ -144,6 +159,9 @@
        function runParser( Revision $revision ) {
                $content = $revision->getContent();
                $content->getParserOutput( $revision->getTitle(), 
$revision->getId() );
+               if ( $this->clearLinkCache ) {
+                       $this->linkCache->clear();
+               }
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/310743
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I75c2cad9a8cf1b41d192708773194f799673ce83
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to