Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/211951
Change subject: Removed filter profiling using $wgMemc ...................................................................... Removed filter profiling using $wgMemc * This is very slow as there can easily be hundreds of filters, each doing 6 memcached queries. Xenon flamegraphs show a lot of time spent in this method, slowing down editing. Change-Id: I31e4502bbd45cc284db3cd89eb34ad365c59905b --- M AbuseFilter.class.php M Views/AbuseFilterViewEdit.php 2 files changed, 2 insertions(+), 72 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter refs/changes/51/211951/1 diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php index a83ead5..fff2ddb 100755 --- a/AbuseFilter.class.php +++ b/AbuseFilter.class.php @@ -539,77 +539,10 @@ $timeTaken = $endTime - $startTime; $condsUsed = $endConds - $startConds; - self::recordProfilingResult( $row->af_id, $timeTaken, $condsUsed ); + // @TODO: log slow/complex filters } return $result; - } - - /** - * @param $filter - */ - public static function resetFilterProfile( $filter ) { - global $wgMemc; - $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); - $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); - - $wgMemc->delete( $countKey ); - $wgMemc->delete( $totalKey ); - } - - /** - * @param $filter - * @param $time - * @param $conds - */ - public static function recordProfilingResult( $filter, $time, $conds ) { - global $wgMemc; - - $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); - $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); - $totalCondKey = wfMemcKey( 'abusefilter', 'profile-conds', 'total' ); - - $curCount = $wgMemc->get( $countKey ); - $curTotal = $wgMemc->get( $totalKey ); - $curTotalConds = $wgMemc->get( $totalCondKey ); - - if ( $curCount ) { - $wgMemc->set( $totalCondKey, $curTotalConds + $conds, 3600 ); - $wgMemc->set( $totalKey, $curTotal + $time, 3600 ); - $wgMemc->incr( $countKey ); - } else { - $wgMemc->set( $countKey, 1, 3600 ); - $wgMemc->set( $totalKey, $time, 3600 ); - $wgMemc->set( $totalCondKey, $conds, 3600 ); - } - } - - /** - * @param $filter - * @return array - */ - public static function getFilterProfile( $filter ) { - global $wgMemc; - - $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); - $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); - $totalCondKey = wfMemcKey( 'abusefilter', 'profile-conds', 'total' ); - - $curCount = $wgMemc->get( $countKey ); - $curTotal = $wgMemc->get( $totalKey ); - $curTotalConds = $wgMemc->get( $totalCondKey ); - - if ( !$curCount ) { - return array( 0, 0 ); - } - - $timeProfile = ( $curTotal / $curCount ) * 1000; // 1000 ms in a sec - $timeProfile = round( $timeProfile, 2 ); // Return in ms, rounded to 2dp - - $condProfile = ( $curTotalConds / $curCount ); - $condProfile = round( $condProfile, 0 ); - - return array( $timeProfile, $condProfile ); } /** diff --git a/Views/AbuseFilterViewEdit.php b/Views/AbuseFilterViewEdit.php index 14dbce0..7f60c56 100755 --- a/Views/AbuseFilterViewEdit.php +++ b/Views/AbuseFilterViewEdit.php @@ -247,8 +247,6 @@ ChangeTags::purgeTagCacheAll(); } - AbuseFilter::resetFilterProfile( $new_id ); - $out->redirect( $this->getTitle()->getLocalURL( array( @@ -380,10 +378,9 @@ if ( $total > 0 ) { $matches_percent = sprintf( '%.2f', 100 * $matches_count / $total ); - list( $timeProfile, $condProfile ) = AbuseFilter::getFilterProfile( $filter ); $fields['abusefilter-edit-status-label'] = $this->msg( 'abusefilter-edit-status' ) - ->numParams( $total, $matches_count, $matches_percent, $timeProfile, $condProfile ) + ->numParams( $total, $matches_count, $matches_percent ) ->escaped(); } } -- To view, visit https://gerrit.wikimedia.org/r/211951 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I31e4502bbd45cc284db3cd89eb34ad365c59905b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/AbuseFilter Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits