Opened 7 years ago

Closed 6 years ago

#4322 closed defect (fixed)

Improve unit selection performance by rearranging GetEntityState following r18773

Reported by: mimo Owned by: echotangoecho
Priority: Should Have Milestone: Alpha 23
Component: UI & Simulation Keywords:
Cc: Imarok Patch: Phab:D1223

Description (last modified by Imarok)

Because of the loop lines 436/442 of gui/session/selection_details.js introduced in r18773, GetExtendedEntityState is now called for all selected entities while it was designed to complete the EntityState with the rarely used variables and be called only on rare occasions (usually only the first selected entity) when needed. Testing on Combat Demo Huge by selecting 200 units without doing anything, the "gui sim update" profile info goes from about 29ms/turn when calling only GetEntityState in that loop (so missing a few variables) to 47 ms/turn with the current GetExtendedEntityState.

  • We should then move the info needed by displayMultiple from ExtendedEntityState to EntityState and only call GetEntityState in that new loop.
  • If it happens that everything is now needed, then the distinction between EntityState and GetEntityState would have no more meaning, and they should be merged (that would simplify a bit the code, and avoid some now useless steps).
  • And maybe a way to improve performances when a lot of selected units would be to call the GuiInterface GetEntityState for an array of entities, such that all the selected units would need only one call instead of one per entity.

Change History (11)

comment:1 by elexis, 7 years ago

Keywords: simple added
Summary: Increase in "gui sim update" timing after r18773Improve unit selection performance by rearranging GetEntityState following r18773

comment:2 by Imarok, 7 years ago

Cc: Imarok added

comment:3 by Imarok, 7 years ago

At the first glance it seems like only barterMarket is needed from GetExtendedEntityState

comment:4 by mimo, 7 years ago

In fact, we add the prices in the barketMarket ExtendedEntityState while this is useless as the prices are global and already in the SimulationState. barterMarket could become a simple bool property instead of the current object, and moved to EntityState.

comment:5 by Imarok, 7 years ago

Description: modified (diff)

Looking at the old L328 in selection_details.js at r18773 it seems like we already queried for all selected extended entity states before r18773...

comment:6 by mimo, 7 years ago

hum yes, it seems that the first commit adding them was r18733, a few days before 18773

comment:7 by Imarok, 6 years ago

Owner: set to Imarok
Status: newassigned

comment:8 by Imarok, 6 years ago

Investigating further, it seems like nearly everything (of extended and non-extended entState) is now needed everytime.

Edit: Requesting an array of entityStates has a performance benefit of about 20% (before caching).

Last edited 6 years ago by Imarok (previous) (diff)

comment:9 by echotangoecho, 6 years ago

Owner: changed from Imarok to echotangoecho
Status: assignednew

comment:10 by Imarok, 6 years ago

Patch: Phab:D1223

comment:11 by mimo, 6 years ago

Keywords: simple removed
Milestone: BacklogAlpha 23
Resolution: fixed
Status: newclosed

Fixed by r20875 corresponding to phab:D1223

Note: See TracTickets for help on using tickets.