Skip to content

Conversation

@Enderlook
Copy link
Contributor

Improve perfomance by reducing memory allocations per frame and GC pressure when using FMOD engine.

In an scene test of mine, I had 158 SteamAudioSources. Without this commit, SteamAudioSource.Update() took 3.77 ms per frame (7.2% of CPU budget) and allocated 137 kb per frame. After this commit, it took 2.8 ms per frame (5.8%) and allocates 79.8 kb per frame. That is a ~25% perfomance improvement in CPU and ~41% less of garbage for the GC.

For further improvement reflection should be eliminated (not shown in this commit). With my own tests I figured out it can reduce time to 0.17 ms (0.3%) and no garbage, equivalent to ~95% perfomance improvement. I did this by creating a new script without reflection (I can pass if you want) and then instantiating it with reflection (so reflection is only using at creation rather per update). However this script is outside Steam Audio library which is why it can have a reference to both Steam Audio and FMOD content. How to do this inside Steam Audio remains as a question...

…nd GC pressure when using FMOD engine

In an scene test of mine, I had 158 SteamAudioSources.
Without this commit, SteamAudioSource.Update() took 3.77 ms per frame (7.2% of CPU budget) and allocated 137 kb per frame.
After this commit, it took 2.8 ms per frame (5.8%) and allocates 79.8 kb per frame.
That is a ~25% perfomance improvement in CPU and ~41% less of garbage for the GC.

For further improvement reflection should be eliminated. My tests show it can reduce time to 0.17 ms (0.3%) and 0 bytes of garbage, equivalent to ~95% perfomance improvement. Although it remains a question how to do that.
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