Skip to content

Optimisation - Removed a lot of garbage allocation #1804

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

Merged
merged 2 commits into from
Mar 19, 2019
Merged

Optimisation - Removed a lot of garbage allocation #1804

merged 2 commits into from
Mar 19, 2019

Conversation

tkggwatson
Copy link
Contributor

Hi,

In this change, I've made various changes that keep the functionality the same whilst creating a lot less garbage. This results in faster training and less GC Collect spikes during playback.

I hope you find them useful.

Regards
Graham

- Changed a few IEnumerable instances to IReadOnlyList. This avoids some unnecessary GC allocs that cast the Lists to IEnumerables.
- Moved cdf allocation outside of the loop to avoid unnecessary GC allocation.
- Changed GeneratorImpl to use plain float and int arrays instead of Array during generation. This avoids SetValue performing boxing on the arrays, which eliminates an awful lot of GC allocs.
@Unity-Technologies Unity-Technologies deleted a comment Mar 18, 2019
@vincentpierre vincentpierre merged commit aeeaaad into Unity-Technologies:develop Mar 19, 2019
LeSphax pushed a commit to LeSphax/ml-agents-1 that referenced this pull request May 3, 2020
…s#1804)

* Garbage collection optimisations:
- Changed a few IEnumerable instances to IReadOnlyList. This avoids some unnecessary GC allocs that cast the Lists to IEnumerables.
- Moved cdf allocation outside of the loop to avoid unnecessary GC allocation.
- Changed GeneratorImpl to use plain float and int arrays instead of Array during generation. This avoids SetValue performing boxing on the arrays, which eliminates an awful lot of GC allocs.

* Convert InferenceBrain to use IReadOnlyList to avoid garbage creation.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants