Page MenuHomePhabricator

Significant time optimisation of WordLevelDiff._split
Closed, ResolvedPublic


Author: bnagaev


I faced a problem, that difference involving many lines fails to be rendered in 60 seconds. The reason turned out to be in overhead in method WordLevelDiff._split (file includes/diff/DairikiDiff.php).

$words = array_merge( $words, $m[0] );
$stripped = array_merge( $stripped, $m[1] );

Call of array_merge happens for each line of difference. array_merge is acting too slow, since it involves copying its arguments.

I replaced this two lines with:
foreach ($m[0] as $k) { $words []= $k; }
foreach ($m[1] as $k) { $stripped []= $k; }

This results in significant speed-up of difference rendering (from more than 60 seconds to less than one second).

Version: 1.22.0
Severity: minor



Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:31 AM
bzimport set Reference to bz47989.
bzimport added a subscriber: Unknown Object (MLST).

Hi! Thanks for your bug report!

You are welcome to use Developer access

to submit this change as a Git branch directly into Gerrit:

Putting your branch in Git makes it easier to review it quickly.
Thanks again! We appreciate your contribution.

Thanks, Boris! Looks like Jenkins failed for that patch, plus would be great if you could mention the corresponding bug number in the patch's commit message. See

bnagaev wrote:

Hey, Andre Klapper!

Bug number was mentioned in the patch's commit message. Jenkins-bot now reports build succeeded.

Aklapper closed this task as Resolved.Mar 20 2015, 11:28 PM
Aklapper claimed this task. was merged long ago; closing as resolved.
Please reopen if there's more to fix here.