Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate many one-element arrays in spatials #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Stuy486
Copy link

@Stuy486 Stuy486 commented Apr 20, 2018

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.

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.
Copy link
Contributor

@artch artch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Could anyone test and benchmark it on a working private server?

@Stuy486
Copy link
Author

Stuy486 commented Apr 23, 2018

@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.

@AlinaNova21
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants