X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fprofiler%2FProfiler.php;h=d5cdf2886664f09eb236c77d58d33ae81dee3798;hb=698cfad8b9380f070e53dd24475cac9dbb3b401b;hp=f6bafd5d7d89f53ad986ecca4543ddb2d0522524;hpb=926f665234e72ea5905bcb239d1f7a32b488f875;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index f6bafd5d7d..d5cdf28866 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -357,8 +357,8 @@ abstract class Profiler { */ class TransactionProfiler { /** @var float seconds */ - protected $mDBLockThreshold = 5.0; - /** @var array DB/server name => (active trx count,timestamp) */ + protected $mDBLockThreshold = 3.0; + /** @var array DB/server name => (active trx count, time, DBs involved) */ protected $mDBTrxHoldingLocks = array(); /** @var array DB/server name => list of (function name, elapsed time) */ protected $mDBTrxMethodTimes = array(); @@ -370,16 +370,20 @@ class TransactionProfiler { * * @param string $server DB server * @param string $db DB name - * @param string $id Resource ID string of connection + * @param string $id ID string of transaction */ public function transactionWritingIn( $server, $db, $id ) { - $name = "{$server} ({$db}) ($id)"; + $name = "{$server} ({$db}) (TRX#$id)"; if ( isset( $this->mDBTrxHoldingLocks[$name] ) ) { ++$this->mDBTrxHoldingLocks[$name]['refs']; } else { - $this->mDBTrxHoldingLocks[$name] = array( 'refs' => 1, 'start' => microtime( true ) ); + $this->mDBTrxHoldingLocks[$name] = array( + 'refs' => 1, 'start' => microtime( true ), 'conns' => array() ); $this->mDBTrxMethodTimes[$name] = array(); } + foreach ( $this->mDBTrxHoldingLocks as $name => &$info ) { + $info['conns'][$name] = 1; // track all DBs in transactions for this transaction + } } /** @@ -417,22 +421,22 @@ class TransactionProfiler { * * @param string $server DB server * @param string $db DB name - * @param string $id Resource ID string of connection + * @param string $id ID string of transaction */ public function transactionWritingOut( $server, $db, $id ) { - $name = "{$server} ({$db}) ($id)"; + $name = "{$server} ({$db}) (TRX#$id)"; if ( --$this->mDBTrxHoldingLocks[$name]['refs'] <= 0 ) { $slow = false; foreach ( $this->mDBTrxMethodTimes[$name] as $info ) { - list( $method, $realtime ) = $info; + $realtime = $info[1]; if ( $realtime >= $this->mDBLockThreshold ) { $slow = true; break; } } if ( $slow ) { - $dbs = implode( ', ', array_keys( $this->mDBTrxHoldingLocks ) ); - $msg = "Sub-optimal transaction on DB(s) {$dbs}:\n"; + $dbs = implode( ', ', array_keys( $this->mDBTrxHoldingLocks[$name]['conns'] ) ); + $msg = "Sub-optimal transaction on DB(s) [{$dbs}]:\n"; foreach ( $this->mDBTrxMethodTimes[$name] as $i => $info ) { list( $method, $realtime ) = $info; $msg .= sprintf( "%d\t%.6f\t%s\n", $i, $realtime, $method );