From 3226337f17825b1c9e4465cd9635ae83c2ef11c0 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 7 Jan 2015 14:19:06 -0800 Subject: [PATCH] Converted some section profiling to scopedProfileIn Change-Id: If69de34a046f4f33fc57b93beaf264f522ce7386 --- includes/cache/bloom/BloomCache.php | 16 +++---- includes/db/LoadBalancer.php | 2 - includes/filebackend/FileBackendStore.php | 56 +++++++++++------------ includes/filebackend/SwiftFileBackend.php | 8 ++-- 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/includes/cache/bloom/BloomCache.php b/includes/cache/bloom/BloomCache.php index ef15bb1896..2720933464 100644 --- a/includes/cache/bloom/BloomCache.php +++ b/includes/cache/bloom/BloomCache.php @@ -94,7 +94,7 @@ abstract class BloomCache { * @return bool True if set, false if not (also returns true on error) */ final public function check( $domain, $type, $member ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); if ( method_exists( "BloomFilter{$type}", 'mergeAndCheck' ) ) { try { @@ -132,7 +132,7 @@ abstract class BloomCache { * @return bool Success */ final public function insert( $domain, $type, $members ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); if ( method_exists( "BloomFilter{$type}", 'mergeAndCheck' ) ) { try { @@ -161,7 +161,7 @@ abstract class BloomCache { * @return bool Success */ final public function init( $key, $size = 1000000, $precision = .001 ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); return $this->doInit( "{$this->cacheID}:$key", $size, min( .1, $precision ) ); } @@ -174,7 +174,7 @@ abstract class BloomCache { * @return bool Success */ final public function add( $key, $members ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); return $this->doAdd( "{$this->cacheID}:$key", (array)$members ); } @@ -193,7 +193,7 @@ abstract class BloomCache { * @return bool|null True if set, false if not, null on error */ final public function isHit( $key, $member ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); return $this->doIsHit( "{$this->cacheID}:$key", $member ); } @@ -205,7 +205,7 @@ abstract class BloomCache { * @return bool Success */ final public function delete( $key ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); return $this->doDelete( "{$this->cacheID}:$key" ); } @@ -218,7 +218,7 @@ abstract class BloomCache { * @return bool Success */ final public function setStatus( $virtualKey, array $values ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); return $this->doSetStatus( "{$this->cacheID}:$virtualKey", $values ); } @@ -236,7 +236,7 @@ abstract class BloomCache { * @return array|bool False on failure */ final public function getStatus( $virtualKey ) { - $section = new ProfileSection( get_class( $this ) . '::' . __FUNCTION__ ); + $ps = Profiler::instance()->scopedProfileIn( get_class( $this ) . '::' . __FUNCTION__ ); return $this->doGetStatus( "{$this->cacheID}:$virtualKey" ); } diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 789715ab15..f789d56ac1 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -224,8 +224,6 @@ class LoadBalancer { return $this->mReadIndex; } - new ProfileSection( __METHOD__ ); - # Find the relevant load array if ( $group !== false ) { if ( isset( $this->mGroupLoads[$group] ) ) { diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 06fb2c6e66..23d9f731f4 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -118,7 +118,7 @@ abstract class FileBackendStore extends FileBackend { * @return Status */ final public function createInternal( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); if ( strlen( $params['content'] ) > $this->maxFileSizeInternal() ) { $status = Status::newFatal( 'backend-fail-maxsize', $params['dst'], $this->maxFileSizeInternal() ); @@ -159,7 +159,7 @@ abstract class FileBackendStore extends FileBackend { * @return Status */ final public function storeInternal( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); if ( filesize( $params['src'] ) > $this->maxFileSizeInternal() ) { $status = Status::newFatal( 'backend-fail-maxsize', $params['dst'], $this->maxFileSizeInternal() ); @@ -201,7 +201,7 @@ abstract class FileBackendStore extends FileBackend { * @return Status */ final public function copyInternal( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = $this->doCopyInternal( $params ); $this->clearCache( array( $params['dst'] ) ); if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) { @@ -233,7 +233,7 @@ abstract class FileBackendStore extends FileBackend { * @return Status */ final public function deleteInternal( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = $this->doDeleteInternal( $params ); $this->clearCache( array( $params['src'] ) ); $this->deleteFileCache( $params['src'] ); // persistent cache @@ -267,7 +267,7 @@ abstract class FileBackendStore extends FileBackend { * @return Status */ final public function moveInternal( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = $this->doMoveInternal( $params ); $this->clearCache( array( $params['src'], $params['dst'] ) ); $this->deleteFileCache( $params['src'] ); // persistent cache @@ -313,7 +313,7 @@ abstract class FileBackendStore extends FileBackend { * @return Status */ final public function describeInternal( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); if ( count( $params['headers'] ) ) { $status = $this->doDescribeInternal( $params ); $this->clearCache( array( $params['src'] ) ); @@ -346,7 +346,7 @@ abstract class FileBackendStore extends FileBackend { } final public function concatenate( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); // Try to lock the source files for the scope of this function @@ -439,7 +439,7 @@ abstract class FileBackendStore extends FileBackend { } final protected function doPrepare( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] ); @@ -474,7 +474,7 @@ abstract class FileBackendStore extends FileBackend { } final protected function doSecure( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] ); @@ -509,7 +509,7 @@ abstract class FileBackendStore extends FileBackend { } final protected function doPublish( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] ); @@ -544,7 +544,7 @@ abstract class FileBackendStore extends FileBackend { } final protected function doClean( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); // Recursive: first delete all empty subdirs recursively @@ -600,21 +600,21 @@ abstract class FileBackendStore extends FileBackend { } final public function fileExists( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $stat = $this->getFileStat( $params ); return ( $stat === null ) ? null : (bool)$stat; // null => failure } final public function getFileTimestamp( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $stat = $this->getFileStat( $params ); return $stat ? $stat['mtime'] : false; } final public function getFileSize( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $stat = $this->getFileStat( $params ); return $stat ? $stat['size'] : false; @@ -625,7 +625,7 @@ abstract class FileBackendStore extends FileBackend { if ( $path === null ) { return false; // invalid storage path } - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $latest = !empty( $params['latest'] ); // use latest data? if ( !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) { $this->primeFileCache( array( $path ) ); // check persistent cache @@ -679,7 +679,7 @@ abstract class FileBackendStore extends FileBackend { abstract protected function doGetFileStat( array $params ); public function getFileContentsMulti( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $params = $this->setConcurrencyFlags( $params ); $contents = $this->doGetFileContentsMulti( $params ); @@ -708,7 +708,7 @@ abstract class FileBackendStore extends FileBackend { if ( $path === null ) { return false; // invalid storage path } - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $latest = !empty( $params['latest'] ); // use latest data? if ( $this->cheapCache->has( $path, 'xattr', self::CACHE_TTL ) ) { $stat = $this->cheapCache->get( $path, 'xattr' ); @@ -742,7 +742,7 @@ abstract class FileBackendStore extends FileBackend { if ( $path === null ) { return false; // invalid storage path } - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $latest = !empty( $params['latest'] ); // use latest data? if ( $this->cheapCache->has( $path, 'sha1', self::CACHE_TTL ) ) { $stat = $this->cheapCache->get( $path, 'sha1' ); @@ -775,7 +775,7 @@ abstract class FileBackendStore extends FileBackend { } final public function getFileProps( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $fsFile = $this->getLocalReference( $params ); $props = $fsFile ? $fsFile->getProps() : FSFile::placeholderProps(); @@ -783,7 +783,7 @@ abstract class FileBackendStore extends FileBackend { } final public function getLocalReferenceMulti( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $params = $this->setConcurrencyFlags( $params ); @@ -826,7 +826,7 @@ abstract class FileBackendStore extends FileBackend { } final public function getLocalCopyMulti( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $params = $this->setConcurrencyFlags( $params ); $tmpFiles = $this->doGetLocalCopyMulti( $params ); @@ -851,7 +851,7 @@ abstract class FileBackendStore extends FileBackend { } final public function streamFile( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); $info = $this->getFileStat( $params ); @@ -1071,7 +1071,7 @@ abstract class FileBackendStore extends FileBackend { } final protected function doOperationsInternal( array $ops, array $opts ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); // Fix up custom header name/value pairs... @@ -1137,7 +1137,7 @@ abstract class FileBackendStore extends FileBackend { } final protected function doQuickOperationsInternal( array $ops ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $status = Status::newGood(); // Fix up custom header name/value pairs... @@ -1204,7 +1204,7 @@ abstract class FileBackendStore extends FileBackend { * @return array Map of Status objects */ final public function executeOpHandlesInternal( array $fileOpHandles ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); foreach ( $fileOpHandles as $fileOpHandle ) { if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) { @@ -1300,7 +1300,7 @@ abstract class FileBackendStore extends FileBackend { } final public function preloadFileStat( array $params ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $success = true; // no network errors $params['concurrency'] = ( $this->parallelize !== 'off' ) ? $this->concurrency : 1; @@ -1623,7 +1623,7 @@ abstract class FileBackendStore extends FileBackend { * @param array $items */ final protected function primeContainerCache( array $items ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $paths = array(); // list of storage paths $contNames = array(); // (cache key => resolved container name) @@ -1733,7 +1733,7 @@ abstract class FileBackendStore extends FileBackend { * @param array $items List of storage paths */ final protected function primeFileCache( array $items ) { - $section = new ProfileSection( __METHOD__ . "-{$this->name}" ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $paths = array(); // list of storage paths $pathNames = array(); // (cache key => storage path) diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 7234474081..1f7ebc9a17 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -664,7 +664,7 @@ class SwiftFileBackend extends FileBackendStore { return $objHdrs; // nothing to do } - $section = new ProfileSection( __METHOD__ . '-' . $this->name ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); trigger_error( "$path was not stored with SHA-1 metadata.", E_USER_WARNING ); $auth = $this->getAuthentication(); @@ -798,7 +798,7 @@ class SwiftFileBackend extends FileBackendStore { return $dirs; // nothing more } - $section = new ProfileSection( __METHOD__ . '-' . $this->name ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $prefix = ( $dir == '' ) ? null : "{$dir}/"; // Non-recursive: only list dirs right under $dir @@ -878,7 +878,7 @@ class SwiftFileBackend extends FileBackendStore { return $files; // nothing more } - $section = new ProfileSection( __METHOD__ . '-' . $this->name ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); $prefix = ( $dir == '' ) ? null : "{$dir}/"; // $objects will contain a list of unfiltered names or CF_Object items @@ -1272,7 +1272,7 @@ class SwiftFileBackend extends FileBackendStore { * @return array|bool|null False on 404, null on failure */ protected function getContainerStat( $container, $bypassCache = false ) { - $section = new ProfileSection( __METHOD__ . '-' . $this->name ); + $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" ); if ( $bypassCache ) { // purge cache $this->containerStatCache->clear( $container ); -- 2.20.1