Page MenuHomePhabricator

Adding a table column in Visual Editor takes time exponentially proportional to row count
Closed, DuplicatePublic

Description

I'm using Firefox 53.0.3 on Ubuntu, and was working on this page: https://www.mediawiki.org/wiki/User:KSmith_(WMF)/Technology_programs

I created a table (default 5x5), and entered all the departments names in the leftmost column. The remaining columns were all empty, and there was no other content on the page. Then I started inserting additional columns, and each insert takes about 10 seconds. It doesn't seem to matter whether I insert before or after. It doesn't seem to be getting slower (or faster) as the table grows. I have measured times between 8 and 12 seconds. That seems unexpectedly slow.

Event Timeline

Reproduced, in Chromium58/Ubuntu and Firefox53/Ubuntu.
The issue seems to be based on the number of rows
I made a test page, with 4 tables, here
https://www.mediawiki.org/w/index.php?title=User:Quiddity_(WMF)/sandbox2&oldid=2480122
Adding a new column to the 34x10 row table is instant.
Adding a new column to the 34x15 row table takes ~5 seconds.
Adding a new column to the 34x20 row table takes ~60 seconds.
Adding a new column to the 10x20 row table takes ~30 seconds.

Definitely related to row count, seems exponential. Debugging shows that each execution of the transactions.forEach() loop at the end of insertRowOrCol takes at least twice as long as the last one.

This makes it completely impossible to insert a column in a table with 36 rows, which is usually one of the killer features of VE!

Slowness traced to ve.dm.Surface.prototye.change, line 873 in debug=true version.
this.emit( 'select', this.selection.clone() );

Ejegg renamed this task from Adding a table column in Visual Editor takes about 10 seconds to Adding a table column in Visual Editor takes time exponentially proportional to row count.Jun 5 2017, 8:02 PM
Ejegg added a project: MediaWiki-Page-editing.

Looks like select events getting bound and not unbound. this.bindings[select].length is twice as big each time through the trasnactions.forEach() loop, so the loop inside of oo.EventEmitter.emit takes twice as long each time.