Page MenuHomePhabricator

Element#updateThemeClasses results in a separate setTimeout for each widget, which has some overhead, making it slow
Closed, ResolvedPublic

Description

Element#updateThemeClasses results in a separate setTimeout() call for each widget, which has some overhead, making it slow. For example, the demo currently creates 588 timeouts for this, and we have interfaces larger than that in production (e.g. UploadWizard with 50 uploads, VE transclusion dialog for big transclusions).

There is some small overhead associated with each setTimeout() call (in Chrome, ~0.035 ms); there is some more overhead when the timeout is called (in Chrome, ~0.025 ms); it becomes noticeable when we set up 10,000 timeouts.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 23 2016, 12:39 PM

I've been measuring the overhead with these two small test cases. These will print the wall clock time it takes to set up the timeouts, and the time it takes to run them.

  • Do 10,000 setTimeout() calls:
  • Do 1 setTimeout() call, which calls 10,000 functions:

Change 328363 had a related patch set uploaded (by Bartosz Dziewoński):
[WIP] Element: Batch setTimeout() calls for #updateThemeClasses

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

Volker_E moved this task from Backlog to Reviewing on the OOUI board.Jan 3 2017, 10:29 PM
matmarex triaged this task as Normal priority.Jan 11 2017, 6:16 PM

Change 328363 merged by jenkins-bot:
Element: Batch setTimeout() calls for #updateThemeClasses

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

Jdforrester-WMF closed this task as Resolved.Jan 13 2017, 4:17 PM
Jdforrester-WMF moved this task from Reviewing to OOjs-UI-0.18.4 on the OOUI board.
Jdforrester-WMF edited projects, added OOUI (OOjs-UI-0.18.4); removed OOUI.
Jdforrester-WMF removed a project: Patch-For-Review.