[MediaWiki-commits] [Gerrit] LoggerFactory: Only check for Psr\Log\LoggerInterface once - change (mediawiki/core)

2015-10-27 Thread Ori.livneh (Code Review)
Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/249297

Change subject: LoggerFactory: Only check for Psr\Log\LoggerInterface once
..

LoggerFactory: Only check for Psr\Log\LoggerInterface once

LoggerFactory::getInstance() will be called many times during the course
of handling a typical MediaWiki request. The interface_exists() guard
condition it uses is an attempt to provide an informative error message
when Composer managed libraries are not installed. This check is only
needed on the first invocation of getInstance() to be effective. Using
an additional boolean to guard the interface_exists() call will allow
the PHP runtime to avoid a potentially expensive (at least compared to
a static boolean comparison) function call.

This is the sort of thing that smells of premature optimization, but its
addition is in fact informed by examination of performance reports from
the Wikimedia production environment.

Bug: T115729
Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
(cherry picked from commit 701b9a0dc8f84326b558059e7e0d70d671a828e3)
---
M includes/debug/logger/LoggerFactory.php
1 file changed, 16 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/97/249297/1

diff --git a/includes/debug/logger/LoggerFactory.php 
b/includes/debug/logger/LoggerFactory.php
index f1b24e7..92fbb46 100644
--- a/includes/debug/logger/LoggerFactory.php
+++ b/includes/debug/logger/LoggerFactory.php
@@ -94,18 +94,22 @@
 * @return \\Psr\\Log\\LoggerInterface
 */
public static function getInstance( $channel ) {
-   if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) {
-   $message = (
-   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
-   "library to be present. This library is not 
embedded directly in MediaWiki's " .
-   "git repository and must be installed 
separately by the end user.\n\n" .
-   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
-   '#Fetch_external_libraries">mediawiki.org 
for help on installing ' .
-   'the required components.'
-   );
-   echo $message;
-   trigger_error( $message, E_USER_ERROR );
-   die( 1 );
+   static $hasPSR3Interface = null;
+   if ( $hasPSR3Interface === null ) {
+   $hasPSR3Interface = interface_exists( 
'\Psr\Log\LoggerInterface' );
+   if ( !$hasPSR3Interface ) {
+   $message = (
+   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
+   "library to be present. This 
library is not embedded directly in MediaWiki's " .
+   "git repository and must be installed 
separately by the end user.\n\n" .
+   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
+   
'#Fetch_external_libraries">mediawiki.org for help on installing ' .
+   'the required components.'
+   );
+   echo $message;
+   trigger_error( $message, E_USER_ERROR );
+   die( 1 );
+   }
}
 
return self::getProvider()->getLogger( $channel );

-- 
To view, visit https://gerrit.wikimedia.org/r/249297
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.27.0-wmf.3
Gerrit-Owner: Ori.livneh 
Gerrit-Reviewer: BryanDavis 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] LoggerFactory: Only check for Psr\Log\LoggerInterface once - change (mediawiki/core)

2015-10-27 Thread Ori.livneh (Code Review)
Ori.livneh has submitted this change and it was merged.

Change subject: LoggerFactory: Only check for Psr\Log\LoggerInterface once
..


LoggerFactory: Only check for Psr\Log\LoggerInterface once

LoggerFactory::getInstance() will be called many times during the course
of handling a typical MediaWiki request. The interface_exists() guard
condition it uses is an attempt to provide an informative error message
when Composer managed libraries are not installed. This check is only
needed on the first invocation of getInstance() to be effective. Using
an additional boolean to guard the interface_exists() call will allow
the PHP runtime to avoid a potentially expensive (at least compared to
a static boolean comparison) function call.

This is the sort of thing that smells of premature optimization, but its
addition is in fact informed by examination of performance reports from
the Wikimedia production environment.

Bug: T115729
Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
(cherry picked from commit 701b9a0dc8f84326b558059e7e0d70d671a828e3)
---
M includes/debug/logger/LoggerFactory.php
1 file changed, 16 insertions(+), 12 deletions(-)

Approvals:
  Ori.livneh: Verified; Looks good to me, approved



diff --git a/includes/debug/logger/LoggerFactory.php 
b/includes/debug/logger/LoggerFactory.php
index f1b24e7..92fbb46 100644
--- a/includes/debug/logger/LoggerFactory.php
+++ b/includes/debug/logger/LoggerFactory.php
@@ -94,18 +94,22 @@
 * @return \\Psr\\Log\\LoggerInterface
 */
public static function getInstance( $channel ) {
-   if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) {
-   $message = (
-   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
-   "library to be present. This library is not 
embedded directly in MediaWiki's " .
-   "git repository and must be installed 
separately by the end user.\n\n" .
-   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
-   '#Fetch_external_libraries">mediawiki.org 
for help on installing ' .
-   'the required components.'
-   );
-   echo $message;
-   trigger_error( $message, E_USER_ERROR );
-   die( 1 );
+   static $hasPSR3Interface = null;
+   if ( $hasPSR3Interface === null ) {
+   $hasPSR3Interface = interface_exists( 
'\Psr\Log\LoggerInterface' );
+   if ( !$hasPSR3Interface ) {
+   $message = (
+   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
+   "library to be present. This 
library is not embedded directly in MediaWiki's " .
+   "git repository and must be installed 
separately by the end user.\n\n" .
+   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
+   
'#Fetch_external_libraries">mediawiki.org for help on installing ' .
+   'the required components.'
+   );
+   echo $message;
+   trigger_error( $message, E_USER_ERROR );
+   die( 1 );
+   }
}
 
return self::getProvider()->getLogger( $channel );

-- 
To view, visit https://gerrit.wikimedia.org/r/249297
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.27.0-wmf.3
Gerrit-Owner: Ori.livneh 
Gerrit-Reviewer: BryanDavis 
Gerrit-Reviewer: Ori.livneh 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] LoggerFactory: Only check for Psr\Log\LoggerInterface once - change (mediawiki/core)

2015-10-26 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: LoggerFactory: Only check for Psr\Log\LoggerInterface once
..


LoggerFactory: Only check for Psr\Log\LoggerInterface once

LoggerFactory::getInstance() will be called many times during the course
of handling a typical MediaWiki request. The interface_exists() guard
condition it uses is an attempt to provide an informative error message
when Composer managed libraries are not installed. This check is only
needed on the first invocation of getInstance() to be effective. Using
an additional boolean to guard the interface_exists() call will allow
the PHP runtime to avoid a potentially expensive (at least compared to
a static boolean comparison) function call.

This is the sort of thing that smells of premature optimization, but its
addition is in fact informed by examination of performance reports from
the Wikimedia production environment.

Bug: T115729
Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
---
M includes/debug/logger/LoggerFactory.php
1 file changed, 16 insertions(+), 12 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/debug/logger/LoggerFactory.php 
b/includes/debug/logger/LoggerFactory.php
index f1b24e7..92fbb46 100644
--- a/includes/debug/logger/LoggerFactory.php
+++ b/includes/debug/logger/LoggerFactory.php
@@ -94,18 +94,22 @@
 * @return \\Psr\\Log\\LoggerInterface
 */
public static function getInstance( $channel ) {
-   if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) {
-   $message = (
-   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
-   "library to be present. This library is not 
embedded directly in MediaWiki's " .
-   "git repository and must be installed 
separately by the end user.\n\n" .
-   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
-   '#Fetch_external_libraries">mediawiki.org 
for help on installing ' .
-   'the required components.'
-   );
-   echo $message;
-   trigger_error( $message, E_USER_ERROR );
-   die( 1 );
+   static $hasPSR3Interface = null;
+   if ( $hasPSR3Interface === null ) {
+   $hasPSR3Interface = interface_exists( 
'\Psr\Log\LoggerInterface' );
+   if ( !$hasPSR3Interface ) {
+   $message = (
+   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
+   "library to be present. This 
library is not embedded directly in MediaWiki's " .
+   "git repository and must be installed 
separately by the end user.\n\n" .
+   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
+   
'#Fetch_external_libraries">mediawiki.org for help on installing ' .
+   'the required components.'
+   );
+   echo $message;
+   trigger_error( $message, E_USER_ERROR );
+   die( 1 );
+   }
}
 
return self::getProvider()->getLogger( $channel );

-- 
To view, visit https://gerrit.wikimedia.org/r/248650
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: BryanDavis 
Gerrit-Reviewer: BryanDavis 
Gerrit-Reviewer: Gergő Tisza 
Gerrit-Reviewer: Krinkle 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Ori.livneh 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] LoggerFactory: Only check for Psr\Log\LoggerInterface once - change (mediawiki/core)

2015-10-24 Thread BryanDavis (Code Review)
BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/248650

Change subject: LoggerFactory: Only check for Psr\Log\LoggerInterface once
..

LoggerFactory: Only check for Psr\Log\LoggerInterface once

LoggerFactory::getInstance() will be called many times during the course
of handling a typical MediaWiki request. The interface_exists() guard
condition it uses is an attempt to provide an informative error message
when Composer managed libraries are not installed. This check is only
needed on the first invocation of getInstance() to be effective. Using
an additional boolean to guard the interface_exists() call will allow
the PHP runtime to avoid a potentially expensive (at elast compared to
a static boolean comparison) function call.

This is the sort of thing that smells of premature optimization, but its
addition is in fact informed by examination of performance reports from
the Wikimedia production environment.

Bug: T115729
Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
---
M includes/debug/logger/LoggerFactory.php
1 file changed, 16 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/50/248650/1

diff --git a/includes/debug/logger/LoggerFactory.php 
b/includes/debug/logger/LoggerFactory.php
index f1b24e7..56e5f39 100644
--- a/includes/debug/logger/LoggerFactory.php
+++ b/includes/debug/logger/LoggerFactory.php
@@ -94,18 +94,22 @@
 * @return \\Psr\\Log\\LoggerInterface
 */
public static function getInstance( $channel ) {
-   if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) {
-   $message = (
-   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
-   "library to be present. This library is not 
embedded directly in MediaWiki's " .
-   "git repository and must be installed 
separately by the end user.\n\n" .
-   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
-   '#Fetch_external_libraries">mediawiki.org 
for help on installing ' .
-   'the required components.'
-   );
-   echo $message;
-   trigger_error( $message, E_USER_ERROR );
-   die( 1 );
+   static $shouldCheckForInterface = true;
+   if ( $shouldCheckForInterface ) {
+   if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) {
+   $message = (
+   'MediaWiki requires the https://github.com/php-fig/log;>PSR-3 logging ' .
+   "library to be present. This 
library is not embedded directly in MediaWiki's " .
+   "git repository and must be installed 
separately by the end user.\n\n" .
+   'Please see https://www.mediawiki.org/wiki/Download_from_Git' .
+   
'#Fetch_external_libraries">mediawiki.org for help on installing ' .
+   'the required components.'
+   );
+   echo $message;
+   trigger_error( $message, E_USER_ERROR );
+   die( 1 );
+   }
+   $shouldCheckForInterface = false;
}
 
return self::getProvider()->getLogger( $channel );

-- 
To view, visit https://gerrit.wikimedia.org/r/248650
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I437bcb5326b06145081f2b86f6c4d0c8dc1a318c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: BryanDavis 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits