travis-ci/travis-web-log — pull request #7 by gark87 (2014-01-05 09:15:52+00:00)
Title: Improve huge folds performance

Hi all,

Looks like this PL is related to travis-ci/travis-ci#1340 and travis-ci/travis-ci#5

##### Problem description
I've noticed that there is a performance problem in Firefox (both Windows and Linux) on pages like https://travis-ci.org/gark87/scalaz/builds/14647693.
As far as I understand, the reason is that modifying DOM (by _appendChild_) for every line in fold causes too many re-renderings.

##### Patch description
I've removed parent element before DOM modification, so its modification does not cause page re-rendering.
When all modifications are done parent element is put back.
Adding DocumentFragment does not help in this case, because nodes we add with _appendChild_ are already in DOM, so they are removed and cause re-rendering anyway.

##### Performance measurements
I've done measurements inside https://github.com/travis-ci/travis-web.

Using Firebug I've got the following statistics:
*Before: Profile (45300.839ms, 2053410 calls)*

Function	Calls	Percent	Own Time	Time	Avg	Min	Max	File

anonymous	12	72.4%	32799.981ms	37589.045ms	3132.42ms	0.191ms	34239.346ms
folds (line 28)

anonymous	13	2.36%	1069.513ms	1069.711ms	82.285ms	0.029ms	542.088ms
app.js (line 9504)

anonymous	22582	1%	451.817ms	451.817ms	0.02ms	0.015ms	0.137ms
renderer (line 94)

*With DocumentFragment: Profile (47721.987ms, 1792460 calls)*

Function	Calls	Percent	Own Time	Time	Avg	Min	Max	File

anonymous	12	74.26%	35439.336ms	42403.392ms	3533.616ms	0.141ms	38649.96ms
folds (line 28)

anonymous	27	3.67%	1750.26ms	1750.66ms	64.839ms	0.028ms	557.406ms
app.js (line 9504)

anonymous	22582	1.02%	484.991ms	484.991ms	0.021ms	0.016ms	1.505ms
renderer (line 94)

*With parent removing: Profile (17760.342ms, 1839324 calls)*

Function	Calls	Percent	Own Time	Time	Avg	Min	Max	File

anonymous	12	31.03%	5511.057ms	5518.998ms	459.917ms	0.16ms	3115.039ms
folds (line 28)

anonymous	33	10.24%	1818.61ms	1818.89ms	55.118ms	0.028ms	539.406ms
app.js (line 9504)

anonymous	22582	2.54%	450.867ms	450.867ms	0.02ms	0.015ms	0.119ms
renderer (line 94)