Eliminate many one-element arrays in spatials#90
Eliminate many one-element arrays in spatials#90Stuy486 wants to merge 1 commit intoscreeps:masterfrom
Conversation
In the vast majority of cases, there is only one object of a given type at a given location in a room. Storing these objects directly in the spatial lookup tables rather than creating a new one-element array for every object eliminates most of these arrays while still support multiple objects of a type by detecting that case and accounting for it. On my local private server running IVM with a small amount of room objects, this change resulted in a ~15% reduction in heap generated by the for loop over roomObjects in makeGameObject.
artch
left a comment
There was a problem hiding this comment.
Nice! Could anyone test and benchmark it on a working private server?
|
@ags131 Applied this to the S+ server over the weekend. I gathered tick-to-tick heap statistics from my user code before and after the change and saw a relatively small change in overall heap usage (~1% decrease). The data is quite noisy though, so it's hard to draw any real conclusions. Maybe @ags131 can chime in with an changes he saw in CPU usage, but he doesn't have any heap logging for the server. |
|
Overall there didn't seem to be any effect to the tick times, user cpu looked slightly lower, but was noisy enough even with some averaging that its hard to tell. I don't currently have heap logging, as other than the heap report interval for console output, there is no simple way for a mod to hook in and get those values. |
In the vast majority of cases, there is only one object of a given type at a given location in a room. Storing these objects directly in the spatial lookup tables rather than creating a new one-element array for every object eliminates most of these arrays while still support multiple objects of a type by detecting that case and accounting for it.
On my local private server running IVM with a small amount of room objects, this change resulted in a ~15% reduction in heap generated by the for loop over roomObjects in makeGameObject.