Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/279079
Change subject: Request-local caching of revision text
......................................................................
Request-local caching of revision text
It's not uncommon for the revision text of a Scribunto module to be retrieved
half a dozen times or more in the course of a single request. Caching them in
APC is a non-starter, because there is no practical way to determine which keys
are hot, and storing everything in APC is not viable. Request-local caching
gives us much of the benefit with no negative consequences apart from a nominal
increase to memory usage.
Change-Id: I77575d6d0ea2d06fc6c93f664c5407641aab88d9
---
M includes/Revision.php
1 file changed, 9 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/79/279079/1
diff --git a/includes/Revision.php b/includes/Revision.php
index 3db3744..8a76f10 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -1549,14 +1549,21 @@
protected function loadText() {
// Caching may be beneficial for massive use of external storage
global $wgRevisionCacheExpiry;
+ static $processCache = [];
$cache = ObjectCache::getMainWANInstance();
$textId = $this->getTextId();
$key = wfMemcKey( 'revisiontext', 'textid', $textId );
+
+ if ( isset( $processCache[ $key ] ) ) {
+ return $processCache[ $key ];
+ }
+
if ( $wgRevisionCacheExpiry ) {
$text = $cache->get( $key );
if ( is_string( $text ) ) {
wfDebug( __METHOD__ . ": got id $textId from
cache\n" );
+ $processCache[ $key ] = $text;
return $text;
}
}
@@ -1599,6 +1606,8 @@
wfDebugLog( 'Revision', "No blob for text row '$textId'
(revision {$this->getId()})." );
}
+ $processCache[ $key ] = $text;
+
# No negative caching -- negative hits on text rows may be due
to corrupted slave servers
if ( $wgRevisionCacheExpiry && $text !== false ) {
$cache->set( $key, $text, $wgRevisionCacheExpiry );
--
To view, visit https://gerrit.wikimedia.org/r/279079
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I77575d6d0ea2d06fc6c93f664c5407641aab88d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits