Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3717651
T130947.patch
MaxSem (Max Semenik)
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
MaxSem
Mar 25 2016, 10:51 PM
2016-03-25 22:51:27 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
T130947.patch
View Options
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php
index 4fdacc5..b8a4b58 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -842,19 +842,32 @@ class DifferenceEngine extends ContextSource {
* @return bool|string
*/
public function generateTextDiffBody( $otext, $ntext ) {
- $time = microtime( true );
+ $diff = function() use ( $otext, $ntext ) {
+ $time = microtime( true );
- $result = $this->textDiff( $otext, $ntext );
+ $result = $this->textDiff( $otext, $ntext );
- $time = intval( ( microtime( true ) - $time ) * 1000 );
- $this->getStats()->timing( 'diff_time', $time );
- // Log requests slower than 99th percentile
- if ( $time > 100 && $this->mOldPage && $this->mNewPage ) {
- wfDebugLog( 'diff',
- "$time ms diff: {$this->mOldid} -> {$this->mNewid} {$this->mNewPage}" );
+ $time = intval( ( microtime( true ) - $time ) * 1000 );
+ $this->getStats()->timing( 'diff_time', $time );
+ // Log requests slower than 99th percentile
+ if ( $time > 100 && $this->mOldPage && $this->mNewPage ) {
+ wfDebugLog( 'diff',
+ "$time ms diff: {$this->mOldid} -> {$this->mNewid} {$this->mNewPage}" );
+ }
+
+ return $result;
+ };
+
+ // Use PoolCounter if the diff looks like it can be expensive
+ if ( strlen( $otext ) + strlen( $ntext ) > 20000 ) {
+ $work = new PoolCounterWorkViaCallback( 'diff',
+ md5( $otext ) . md5( $ntext ),
+ [ 'doWork' => $diff ]
+ );
+ return $work->execute();
}
- return $result;
+ return $diff();
}
/**
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3573842
Default Alt Text
T130947.patch (1 KB)
Attached To
Mode
T130947: Diff generation should use PoolCounter
Attached
Detach File
Event Timeline
Log In to Comment