Opened 8 years ago

Last modified 6 years ago

#4322 closed defect

Improve unit selection performance by rearranging GetEntityState following r18773 — at Version 5

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

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 (5)

comment:1 by elexis, 8 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...

Note: See TracTickets for help on using tickets.