Page MenuHomePhabricator

Front End Performance: Migrate ZObject internal representation from flat table to nested object
Closed, ResolvedPublic

Description

Description

The ZObject represented on the page is stored in the zobject.js store module as a flat table, where every node (and hence, every child ZObject represented under that node) can be reached directly by any component using its unique row id.

More details about this: https://www.mediawiki.org/wiki/Extension:WikiLambda/Frontend_Architecture#ZObject_Table

While this data structure is beneficial for direct node value access, it is not scalable with large objects.

More details about performance issue: https://docs.google.com/document/d/1q-AkqLXx0jT43eLj1IxBqE6XpjHRqFdeiwNh4buaAzQ/edit?tab=t.0

We have tried a number of mitigation strategies and the performance improvements are minimal. We've determined it is high priority to move away from flat table representation and into nested object, using Pinia store reference features.

The following POC has shown this possibility performs well, loads immediately and doesn't require an excessive refactor:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikiLambda/+/1126604

json-rendering-2.gif (992×958 px, 1 MB)

Desired behavior/Acceptance criteria

  • ZObject is stored as is (converted to hybrid form) instead of flat table
  • Front-end load times visibly improve
  • UI can load an expanded Q144 wikidata object in a reasonable time with no browser crashes
  • Unit test coverage is equivalent to current
  • UI snapshots are identical
  • Integration and e2e tests pass with no changes
  • Frontend Architecture documentation is updated

Completion checklist

Event Timeline

Change #1126604 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] [WIP] Migrate ZObject internal representation from flat table to nested object

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

DSantamaria added a project: OKR-Work.

Observed improvements on
table 1: Load time
table 2: Browser memory

NameV1 (ms)V2 (ms)Load time improvement ratio
Edit Z199403003001.00×
Edit Z12343173001.06×
Edit Z8682324152.83×
Edit Z41165033073.52×
Edit Z86630270120425.14×
View Z199403093001.03×
View Z12342513000.84×
View Z833796824.95×
View Z4831983210.00×
View Z866395424716.01×
Z6821(Q818363) First request318694.61×
Z6821(Q818363) Subsequent request51487866.00×
Z6821(Q818363) Expand response (all item lists)1343214379.35×
Z6821(Q144) First request9091277.16×
Z6821(Q144) Subsequent request1291261161,113.16×
Z6821(Q144) Expand response (all item lists)6130
NameV1 (MB)V2 (MB)Browser memory improvement %
Edit Z1994059573.39%
Edit Z12345662-10.71%
Edit Z826515840.38%
Edit Z443020253.02%
Edit Z86622710553.74%
View Z1994058538.62%
View Z12345357-7.55%
View Z81577353.50%
View Z42408564.58%
View Z866705521.43%
Z6821(Q818363) First request946135.11%
Z6821(Q818363) Subsequent request1066439.62%
Z6821(Q818363) Expand response (all item lists)53514373.27%
Z6821(Q144) First request1176346.15%
Z6821(Q144) Subsequent request1146642.11%
Z6821(Q144) Expand response (all item lists)500048890.24%

Change #1126604 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Migrate ZObject internal representation from flat table to nested object

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