We have the callout Spring.GetTeamStatsHistory() that can be used to read both current and historical data. This data is mostly comprised of resource and damage statistics. However, the problem here is that even if you would like to read just the current newest data point, the callout has been designed to potentially return multiple data points. Therefore, internally, it allocates a Lua table.
Lua tables are always allocated on the heap. Even if the table would soon be discarded afterwards, the memory manager needs to do work both when allocating and building the table and later on destroying and releasing the memory. When only the newest value is of interest, this is clearly waste.
To poll for real-time resource statistics data, Recoil provides the callout Spring.GetTeamResourceStats(). This callout is used by widgets such as adv_playerlist. However, no such callout exists for polling damage statistics.
Work to do
Add a callout Spring.GetTeamDamageStats() that returns the current damage statistics. Use the implementation of Spring.GetTeamResourceStats() as inspiration on how to implement the new callout without any Lua tables (or other memory on the heap).
Background
We have the callout
Spring.GetTeamStatsHistory()
that can be used to read both current and historical data. This data is mostly comprised of resource and damage statistics. However, the problem here is that even if you would like to read just the current newest data point, the callout has been designed to potentially return multiple data points. Therefore, internally, it allocates a Lua table.Lua tables are always allocated on the heap. Even if the table would soon be discarded afterwards, the memory manager needs to do work both when allocating and building the table and later on destroying and releasing the memory. When only the newest value is of interest, this is clearly waste.
To poll for real-time resource statistics data, Recoil provides the callout
Spring.GetTeamResourceStats()
. This callout is used by widgets such as adv_playerlist. However, no such callout exists for polling damage statistics.Work to do
Add a callout
Spring.GetTeamDamageStats()
that returns the current damage statistics. Use the implementation ofSpring.GetTeamResourceStats()
as inspiration on how to implement the new callout without any Lua tables (or other memory on the heap).Resources
Link to implementation of
Spring.GetTeamResourceStats()
at the time of writing this issue: https://github.com/beyond-all-reason/spring/blob/ca988e28b3e5258e6d23cb85640028e806e146cb/rts/Lua/LuaSyncedRead.cpp#L1902