Revert "Add logging for parser cache misses."

We got the info we wanted, the statistics gathering is now just
causing extra ParserCache lookups.

This reverts commit dd81de53d7.
This reverts commit 9a85a1b67e.

Bug: T266200
Change-Id: I830797e287118fbde07e0e22e1304b30ee9f67e5
This commit is contained in:
daniel 2020-11-17 21:55:58 +01:00 committed by Daniel Kinzler
parent e36f217ba6
commit 4478384155
2 changed files with 0 additions and 74 deletions

View file

@ -1,8 +1,4 @@
<?php
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
/**
* Hooks for TemplateData extension
*
@ -164,8 +160,6 @@ class TemplateDataHooks {
public static function onParserFetchTemplateData( array $tplTitles, array &$tplData ): void {
$tplData = [];
self::logBatchUsage( $tplTitles, 'hook' );
// This inefficient implementation is currently tuned for
// Parsoid's use case where it requests info for exactly one title.
// For a real batch use case, this code will need an overhaul.
@ -207,8 +201,6 @@ class TemplateDataHooks {
continue;
}
self::logParserCacheStatus( $title );
$tdb = TemplateDataBlob::newFromDatabase( wfGetDB( DB_REPLICA ), $props[$pageId] );
$status = $tdb->getStatus();
if ( !$status->isOK() ) {
@ -283,66 +275,4 @@ class TemplateDataHooks {
];
}
}
/**
* @unstable temporary addition to determine whether we can rely on the parser cache for
* storing the parsed TemplateData, instead of putting the data into the page_props table.
*
* @todo Remove once we have gathers sufficient data on live usage patterns (T266200).
*
* @param Title $title
*/
public static function logParserCacheStatus( Title $title ) {
$pageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
$parserCache = MediaWikiServices::getInstance()->getParserCache();
$page = $pageFactory->newFromTitle( $title );
$meta = $parserCache->getMetadata( $page );
$stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
$logger = LoggerFactory::getInstance( 'TemplateData' );
if ( $meta ) {
$stats->updateCount( 'templatedata.parsercache.hit', 1 );
$logger->debug( 'Parser cache hit', [
'template-title' => $title->getPrefixedDBkey(),
] );
} else {
$stats->updateCount( 'templatedata.parsercache.miss', 1 );
$logger->info( 'Parser cache miss', [
'template-title' => $title->getPrefixedDBkey(),
] );
}
}
/**
* @unstable temporary addition to determine whether we can rely on the parser cache for
* storing the parsed TemplateData, instead of putting the data into the page_props table.
*
* @todo Remove once we have gathers sufficient data on live usage patterns (T266200).
*
* @param Title[]|string[] $titles
* @param string $context
*/
public static function logBatchUsage( $titles, $context ) {
$stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
$logger = LoggerFactory::getInstance( 'TemplateData' );
$size = count( $titles );
// magnitude buckets: 1 -> 0, 8 -> 1, 12 -> 2, 78 -> 2, 120 -> 3, ...
$magnitude = $size ? ceil( log10( $size ) ) : 0;
$stats->updateCount( 'templatedata.query.magnitude.' . $magnitude, 1 );
if ( $size < 2 ) {
$logger->debug( 'Single title query', [
'context' => $context,
] );
} else {
$logger->info( 'Batch query', [
'title-count' => $size,
'context' => $context,
] );
}
}
}

View file

@ -69,8 +69,6 @@ class ApiTemplateData extends ApiBase {
$titles = $pageSet->getGoodTitles(); // page_id => Title object
$missingTitles = $pageSet->getMissingTitles(); // page_id => Title object
TemplateDataHooks::logBatchUsage( $pageSet->getTitles(), 'API' );
$includeMissingTitles = $this->getParameter( 'includeMissingTitles' );
$doNotIgnoreMissingTitles = $this->getParameter( 'doNotIgnoreMissingTitles' );
if ( $doNotIgnoreMissingTitles ) {
@ -108,8 +106,6 @@ class ApiTemplateData extends ApiBase {
);
foreach ( $res as $row ) {
TemplateDataHooks::logParserCacheStatus( $titles[$row->pp_page] );
$rawData = $row->pp_value;
$tdb = TemplateDataBlob::newFromDatabase( $db, $rawData );
$status = $tdb->getStatus();