Page MenuHomePhabricator

Highlighting many changes at init time is very slow
Closed, ResolvedPublic

Description

https://en.wikipedia.org/wiki/Special:RecentChanges?hidebots=1&hidecategorization=1&hideWikibase=1&hidelog=1&limit=250&days=14&urlversion=2&damaging=maybebad&damaging__likelybad_color=c3&damaging__verylikelybad_color=c4&goodfaith__verylikelybad_color=c5&highlight=1 spends 2.5 seconds on startup because highlighting is very slow. 80+% of the time spent is in dm.FiltersViewModel#toggleHighlight and functions it calls. 43% of the time is spent in Sizzle, called from .find(), presumably with strange selectors. 14% is spent in querySelectorAll, also from .find().

Event Timeline

Change 381515 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/core@master] RCFilters: Don't apply/clear highlights 66 times

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

I misdiagnosed this a little: yes, the highlights code is somewhat inefficient and could be optimized a bit to use .find() less, and in other ways, but the main problem was that on init we were applying highlights 66 times (and clearing them 64 times). The attached patch reduces this to just two, which is still one too many, but it's already a lot faster.

Change 381515 merged by jenkins-bot:
[mediawiki/core@master] RCFilters: Don't apply/clear highlights 66 times

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

Change 381516 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/core@wmf/1.31.0-wmf.1] RCFilters: Don't apply/clear highlights 66 times

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

Change 381516 merged by jenkins-bot:
[mediawiki/core@wmf/1.31.0-wmf.1] RCFilters: Don't apply/clear highlights 66 times

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

Change 381823 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/core@master] Reapply "RCFilters: Don't apply/clear highlights 66 times"

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

Change 381823 merged by jenkins-bot:
[mediawiki/core@master] Reapply "RCFilters: Don't apply/clear highlights 66 times"

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

Change 381839 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/core@wmf/1.31.0-wmf.1] Reapply "RCFilters: Don't apply/clear highlights 66 times"

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

Change 381839 merged by jenkins-bot:
[mediawiki/core@wmf/1.31.0-wmf.1] Reapply "RCFilters: Don't apply/clear highlights 66 times"

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

Mentioned in SAL (#wikimedia-operations) [2017-10-02T23:36:31Z] <catrope@tin> Synchronized php-1.31.0-wmf.1/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js: T177107 (duration: 00m 47s)

The fix is now actually deployed this time.

Checked in betalabs and cawiki (1.31.0-wmf.2) - no delays with highlighting. However, when there 1,000 changes in 30 days options are selected, the improvement is not noticeable; the range for the page load time increases significantly to avg 17-24s.

Etonkovidova closed this task as Resolved.Oct 5 2017, 12:46 AM