Optimize some poorly performing parts of ASYS. #1658
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This optimizes the "Soft Update" portion of the audio system update. According to my profiling, with 101 male avatars in an Age (resulting in approximately 31,000 sounds loaded), this function would take 7ms on my Ryzen 9 7900X3D. I have something of an overkill CPU, so this kind of drag in the update loop is unacceptable. The problem is that the sounds are all being stored in an intrusive doubly linked list, which is being traversed and partially bubble sorted each update. This pull request changes the container from the intrusive doubly-linked list to an
std::vector
and usesstd::sort()
to sort the active sounds. This change results in the "Soft Update" portion of the update loop only taking about 3ms on my Ryzen 9 7900X3D.As a bonus, I have improved the semantics around accessing the
plSoundBuffer*
fromplSound
objects. There was already aplSoundBuffer*
member variable, but it was only ever set by the exporter. The client code was grabbing an active ref and continually grabbing the object pointer from theplKey
. I have changed this to store theplSoundBuffer*
in the field that already exists, removing the pointless indirection.