Opened 8 years ago

Closed 8 years ago

#528 closed enhancement (wontfix)

Reduce the number of table creations to make less garbage

Reported by: beherith Owned by:
Priority: minor Milestone:
Component: BA trunk Version:
Keywords: Cc:

Description (last modified by beherith)

For example, widgets could share 'getallunits' in a WG callin. Any thoughts?

4542 \luaui\widgets\gfx_lups_manager.lua

355 local allUnits = Spring.GetAllUnits();

4555 \luaui\widgets\gui_comblast_dgun_range.lua

19 local spGetAllUnits = Spring.GetAllUnits

4555 \luaui\widgets\gui_comblast_dgun_range.lua

133 local visibleUnits = spGetAllUnits()

4556 \luaui\widgets\gui_comCounter.lua

34 local spGetAllUnits = Spring.GetAllUnits

4581 \luaui\widgets\gui_team_platter.lua

43 local spGetAllUnits = Spring.GetAllUnits

4581 \luaui\widgets\gui_team_platter.lua

185 for _,unitID in ipairs(spGetAllUnits()) do

4582 \luaui\widgets\gui_xp.lua

26 local GetAllUnits = Spring.GetAllUnits

4582 \luaui\widgets\gui_xp.lua

92 for _,unitID in pairs( GetAllUnits() ) do

4592 \luaui\widgets\unit_auto_group.lua

57 local GetAllUnits = Spring.GetAllUnits

4592 \luaui\widgets\unit_auto_group.lua

173 local allUnits = GetAllUnits()

4594 \luaui\widgets\unit_comm_nametags.lua

36 local GetAllUnits = Spring.GetAllUnits

4594 \luaui\widgets\unit_comm_nametags.lua

130 local allUnits = GetAllUnits()

Change History (7)

comment:1 by beherith, 8 years ago

Description: modified (diff)

comment:2 by beherith, 8 years ago

Description: modified (diff)

comment:3 by beherith, 8 years ago

Priority: majorminor

Also, it seems that garbage collection does not show up in neither the profiler loads (widget profiler and gadget profiler) nor the Lua load percent in debug mode, the amount we can gain here is probably just a few %.

comment:4 by Bluestone, 8 years ago

Some of those only make extremely rare calls to GetAllUnits and imo it would be best not to include those to keep modularization. These are

gui_comblast_dgun_range.lua, unit_comm_nametags.lua, gui_xp.lua, unit_auto_group.lua, unit_comm_nametags.lua

Also, gui_comCounter.lua doesn't actually call it at all, it's just listed in the localizations!

So from that list only gfx_lups_manager.lua, gui_team_platter.lua would benefit. With a bit of work gui_enemy_spotter (which currently uses spGetVisibleUnits) could also benefit.

For Team Platter and Enemy Spotter, they are just badly written widgets and if better written they would only have very rare uses of GetAllUnits/GetVisibleUnits. In case of lups, idk it well, but maybe also its just lazy coding and lups also doesn't actually need to regularly call GetAllUnits.

Although I agree table creation is something to be wary of, in this case I suspect a better fix is to code Team Platter/Enemy Spotter in a sensible way, and idk about lups.

Last edited 8 years ago by Bluestone (previous) (diff)

comment:5 by Bluestone, 8 years ago

In general - is there any way of telling which (if any) widget/gadgets are creating an unreasonable amout of garbage collection?

comment:6 by Bluestone, 8 years ago

[17:11:02] <[Fx]Bluestone> at worst it might be possible to hack the handlers or put some info into engine to count how many tables are created [17:11:06] <[teh]Beherith[PiRO]> no real method of checking besides enable/disable [17:11:22] <[teh]Beherith[PiRO]> plus it seemed there was no 'one big culprit'

comment:7 by Bluestone, 8 years ago

Resolution: wontfix
Status: newclosed

I think that garbage collection is now not an issue worth attention (since jK optimized it in engine).

Note: See TracTickets for help on using tickets.