Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/324944
Change subject: Factor Uptime into LoadMonitorMySQL ...................................................................... Factor Uptime into LoadMonitorMySQL Change-Id: I0304918659dd4e02ea9787b65fbbe8fe9adb5e0a --- M includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php 1 file changed, 27 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/44/324944/1 diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php b/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php index 45b1d83..3add8d1 100644 --- a/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php +++ b/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php @@ -26,6 +26,8 @@ * @ingroup Database */ class LoadMonitorMySQL extends LoadMonitor { + /** @var integer Warmup time in seconds after mysql starts */ + private $uptimeWarmupTTL; /** @var float What buffer pool use ratio counts as "warm" (e.g. 0.5 for 50% usage) */ private $warmCacheRatio; @@ -34,6 +36,9 @@ ) { parent::__construct( $lb, $srvCache, $cache, $options ); + $this->uptimeWarmupTTL = isset( $options['uptimeWarmupTTL'] ) + ? $options['uptimeWarmupTTL'] + : 3600; $this->warmCacheRatio = isset( $options['warmCacheRatio'] ) ? $options['warmCacheRatio'] : 0.0; @@ -45,24 +50,31 @@ } $weight = 1.0; + + $res = $conn->query( 'SHOW STATUS', false ); + $s = $res ? $conn->fetchObject( $res ) : false; + if ( $s === false ) { + $host = $this->parent->getServerName( $index ); + $this->replLogger->error( __METHOD__ . ": could not get status for $host" ); + + return $weight; // leave weight alone + } + + if ( $this->uptimeWarmupTTL > 0 ) { + $weight *= min( $s->Uptime / $this->uptimeWarmupTTL, 1.0 ); + } + if ( $this->warmCacheRatio > 0 ) { - $res = $conn->query( 'SHOW STATUS', false ); - $s = $res ? $conn->fetchObject( $res ) : false; - if ( $s === false ) { - $host = $this->parent->getServerName( $index ); - $this->replLogger->error( __METHOD__ . ": could not get status for $host" ); + // https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html + if ( $s->Innodb_buffer_pool_pages_total > 0 ) { + $ratio = $s->Innodb_buffer_pool_pages_data / $s->Innodb_buffer_pool_pages_total; + } elseif ( $s->Qcache_total_blocks > 0 ) { + $ratio = 1.0 - $s->Qcache_free_blocks / $s->Qcache_total_blocks; } else { - // https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html - if ( $s->Innodb_buffer_pool_pages_total > 0 ) { - $ratio = $s->Innodb_buffer_pool_pages_data / $s->Innodb_buffer_pool_pages_total; - } elseif ( $s->Qcache_total_blocks > 0 ) { - $ratio = 1.0 - $s->Qcache_free_blocks / $s->Qcache_total_blocks; - } else { - $ratio = 1.0; - } - // Stop caring once $ratio >= $this->warmCacheRatio - $weight *= min( $ratio / $this->warmCacheRatio, 1.0 ); + $ratio = 1.0; } + // Stop caring once $ratio >= $this->warmCacheRatio + $weight *= min( $ratio / $this->warmCacheRatio, 1.0 ); } return $weight; -- To view, visit https://gerrit.wikimedia.org/r/324944 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0304918659dd4e02ea9787b65fbbe8fe9adb5e0a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core 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