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

Perf Improvements: #10

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

Perf Improvements: #10

wants to merge 1 commit into from

Conversation

wmtorode
Copy link
Member

@wmtorode wmtorode commented Jan 6, 2025

StratOps (in particular Resupply helper methods) is showing high up in perf flame graphs of AI think time. Alot of time is spent:

  • Creating and updating TagSets
  • checking if a TagSet contains a resupply tag

To fix this:

  • add a new resupply unit stat to the actor's stat collection
  • on add unit, check the actor's tags, if resupply tag is present, mark it as a resupply unit.
  • remove all other checks for the resupply tag, check the stat instead. This stops tagset duplication and reduces checks for its existence to a single Dictionary lookup and boolean check, instead of iterating over a list.
  • Found that GetAllFriendlies & GetAllDetectedEnemies methods already filter out dead and marked for death units, removed spots where the output of these methods is filtered via linq on these same criteria, avoiding a new enumerable being created, filtered and calls that consume time checking if a unit is dead.

Overall the hope is that this creates a noticable improvement to combat/AI perf.

Notes for future:

  • See if there is away to improve GetAllFriendlies & GetAllDetectedEnemies, maybe caching or something? they are frequently called and do a fair number of checks and list creation overhead.

StratOps (in particular Resupply helper methods) is showing high up in perf flame graphs of AI think time. Alot of time is spent:
 - Creating and updating TagSets
 - checking if a TagSet contains a resupply tag

 To fix this:
 - add a new resupply unit stat to the actor's stat collection
 - on add unit, check the actor's tags, if resupply tag is present, mark it as a resupply unit.
 - remove all other checks for the resupply tag, check the stat instead. This stops tagset duplication and reduces checks for its existence to a single Dictionary lookup and boolean check, instead of iterating over a list.
 - Found that `GetAllFriendlies` & `GetAllDetectedEnemies` methods already filter out dead and marked for death units, removed spots where the output of these methods is filtered via linq on these same criteria, avoiding a new enumerable being created, filtered and calls that consume time checking if a unit is dead.

 Overall the hope is that this creates a noticable improvement to combat/AI perf.

 Notes for future:
 - See if there is away to improve `GetAllFriendlies` & `GetAllDetectedEnemies`, maybe caching or something? they are frequently called and do a fair number of checks and list creation overhead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant