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

Clean up dead units from internal cache of units #48

Open
alkurbatov opened this issue Jan 8, 2020 · 4 comments
Open

Clean up dead units from internal cache of units #48

alkurbatov opened this issue Jan 8, 2020 · 4 comments
Labels
feature New feature or request research

Comments

@alkurbatov
Copy link
Member

Currently, the API tracks every unit created in the game (no matter who owns it). The cache is stored in the tag_to_unit_ map and never cleaned up. As a result we may have quite large memory consumption for significantly large games (e.g. ~40 min) when many units are created and destroyed.

The suggestion is to remove dead units from the cache e.g. after 50 frames so that we can avoid increase in memory consumption.

@alkurbatov alkurbatov added the bug Something isn't working label Jan 8, 2020
@mboedigh
Copy link
Contributor

I'm not sure this is a bug. tag_to_units_ was is for all units ever, and tags_to_existing_units_ was for units in vision on a particular observation.
I'm not sure the cleanup is necessary, since the total number of units created isn't huge. It is limited by the total resources on the map (~15000 minerals) and thus only around 1000 units. Moreover, tag_to_units_ only has a pointer to the unit. unit_pool_ stores the unit, but I rely on units existing in memory even if they are dead.

There are another small issue to consider. There isn't a reliable way to know if a unit is dead. Only units that are in vision get passed to the client during an observation if they are in vision. So if an enemy dies outside of vision we won't hear about it again; There is another bug where death of our own units doesn't reliably trigger an event.

@alkurbatov
Copy link
Member Author

alkurbatov commented Jan 12, 2020

So if an enemy dies outside of vision we won't hear about it again

This seems to be ok as humans also don't receive this info.

I'm not sure the cleanup is necessary, since the total number of units created isn't huge.

The problem is that it tracks every units (larva, eggs, different summons, neutrals) so this could be significantly large number.

@mboedigh
Copy link
Contributor

mboedigh commented Jan 12, 2020 via email

@alkurbatov
Copy link
Member Author

alkurbatov commented Jan 14, 2020

So far we have issues with MicroMachine getting out of memory during long games (>=40 minutes). There are no clues that the reason is this logic but it looks suspicious. I think I should spend more time investigating the current implementation.

@alkurbatov alkurbatov added question research and removed bug Something isn't working labels Feb 7, 2020
@alkurbatov alkurbatov added feature New feature or request and removed question labels May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request research
Projects
None yet
Development

No branches or pull requests

2 participants