Page MenuHomePhabricator

Use ResourceLoader package files to reduce number of CX modules
Open, MediumPublic

Assigned To
None
Authored By
Nikerabbit
Aug 27 2019, 1:54 PM
Referenced Files
F34435968: capture.png
Apr 30 2021, 7:45 PM
F34435950: Screenshot 2021-04-30 at 20.10.33.png
Apr 30 2021, 7:45 PM
F30309584: ext.cx.dashboard.png
Sep 12 2019, 7:51 PM
F30309569: ext.cx.tools.png
Sep 12 2019, 7:51 PM
F30309572: mw.cx.init.png
Sep 12 2019, 7:51 PM
F30309592: mw.cx.tools.png
Sep 12 2019, 7:51 PM
F30309587: mw.cx.init.legacy.png
Sep 12 2019, 7:51 PM
F30309581: mw.cx.visualEditor.png
Sep 12 2019, 7:51 PM

Description

As follow-up to T203695: Drastically reduce the number of ResourceLoader modules that CX creates, we could invest using the new "package files" feature of the resource loader to reduce the number of modules further.

Ideally, we would only have a handful of modules:

  • a couple of main ones: one for dashboard, one for translation view, one for stats
  • small modules for entry points
  • some modules for big reusable components shared between the different main modules

Event Timeline

Pginer-WMF moved this task from Needs Triage to Enhancements on the ContentTranslation board.

Documentation for this is a bit hard to find (T232566: $wgResourceModules documentation is incomplete), but there are examples to copy too.

Krinkle renamed this task from Explore resource loader package files feature as way to reduce number of resource loader modules to Explore ResourceLoader package files feature as way to reduce number of modules.Sep 11 2019, 12:40 PM
Krinkle moved this task from Limbo to Perf recommendation on the Performance-Team (Radar) board.

Some concerns have been raised that reducing the number of modules goes against making reusable code.

I don't have the CX module dependency map right now, but I guess there aren't that many modules that are actually shared across different contexts (entrypoints, stats view, dashboard, translation view).

Also, I believe it would be possible to share some simple modules just by having their scripts included in the packageFiles of multiple modules, though I have not tested this. It does make things complicated though if they have dependencies of their own, or config and styles, which would need to be duplicated.

I wrote a code to analyze RL dependency graph and find things that can be merged, CX modules stood out a lot. Given that dropping each CX module saves 30 GB/day, I put them here and I hope you find them useful. The analysis of course can have false positives (like lazy loading, etc.) but looking at this might help you:

ext.cx.tools.png (251×3 px, 147 KB)

mw.cx.init.png (443×2 px, 113 KB)

mw.cx.visualEditor.png (251×1 px, 58 KB)

ext.cx.dashboard.png (347×906 px, 54 KB)

mw.cx.init.legacy.png (347×1 px, 53 KB)

mw.cx.tools.png (155×912 px, 23 KB)

Thanks! A bunch of those involve CX1 which we would prefer not to touch at all until it is removed completely.

Thanks! A bunch of those involve CX1 which we would prefer not to touch at all until it is removed completely.

Hello, your annoying reminder is here :D, I think the 420 days you mentioned in T203695#5158942 has passed now, shall we drop them?

Change 607921 had a related patch set uploaded (by Santhosh; owner: DannyS712):
[mediawiki/extensions/ContentTranslation@master] Combine single-use resource loader modules into ext.cx.tools

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

Change 607921 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Combine single-use resource loader modules into ext.cx.tools

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

🎉 Thanks for T232369. This change has made a considerable impact, reducing the startup payload for page views by about 2% (or 1.5KB).

There is still a lot of bundling left to do compared to other extensions, but this is a huge leap forward. Thanks all!

Screenshot 2021-04-30 at 20.10.33.png (1×2 px, 468 KB)

capture.png (1×2 px, 190 KB)

(From Grafana: Startup manifest size.)

Krinkle renamed this task from Explore ResourceLoader package files feature as way to reduce number of modules to Use ResourceLoader package files to reduce number of CX modules.Jul 12 2021, 6:22 PM