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

Reduce mongroup object size #59528

Merged
merged 2 commits into from
Jul 23, 2022
Merged

Conversation

jbytheway
Copy link
Contributor

Summary

None

Purpose of change

When monitoring memory usage for the overmap_terrain_coverage test I noticed that a lot was taken up by mongroup objects.

Looking at these objects, they are extremely inefficient in their content. Each was 160 bytes, which is far larger than they needed to be.

In particular, mongroup had a lot of unnecessary point information. It contained its own position in both absolute and overmap-relative coordinates, which was clearly redundant. Also, the target and nemesis_target members were both tripoints but only ever used the x and y members.

Describe the solution

Remove the submap-relative position and add a member to deduce it from the absolute position.

Convert each target from tripoint to point.

This reduces the total size of the struct from 160 bytes to 144 bytes.

Add new debugging output regarding mongroups to the overmap editor to help me test these changes.

Describe alternatives you've considered

There are more improvements possible, but this is a good start.

Testing

Unit tests pass.

I verified that an old save with mongroups loads in the new layout without errors.

Using the new debug output I verified that hordes can spawn and they do still move towards their targets.

Additional context

mongroup had a lot of unnecessary point information in itself.  It
contained its own position in both absolute and overmap-relative
coordinates, which was clearly redundant.  Also, the target and
nemesis_target members were both tripoints but only ever used the x and
y members.

Remove the submap-relative position and add a member to deduce it from
the absolute position.

Convert each target from tripoint to point.

This reduces the total size of the struct from 160 bytes to 144 bytes.
To help debug mongroup issues, add debug output on the overmap editor
with various info about each mongroup on the OMT.
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. Map / Mapgen Overmap, Mapgen, Map extras, Map display json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jul 23, 2022
@dseguin dseguin merged commit 5ab7888 into CleverRaven:master Jul 23, 2022
@jbytheway jbytheway deleted the reduce_mongroup_size branch July 24, 2022 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants