Erase empty object sets #35
Merged
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.
TextureObjectManagerandGLBufferObjectManagerstore sets of objects per profile. When object is deleted it's removed from the set but the manager keeps storing the set. Over time with more profiles being used there are more sets and a lot of them are empty. Still there is overhead on flushing deleted objects because all sets are checked every frame. With this change after objects are deleted from every set we also erase it if it's empty. Overall this increases performance because less number of sets have to be checked. Fixes https://gitlab.com/OpenMW/openmw/-/issues/8918.The performace test is done with openmw using cross_cell_border_with_pause.zip Lua mod. It moves player across many cells via rectangular spiral and then back to the original position and rotation with pauses at start and finish. Following scripts are used to start openmw and collect profiles:
Benchmark scripts
scripts/run/cross_cell_border_with_pause.shscripts/other/perf.shscripts/other/report.shWith https://gitlab.com/elsid/openmw/-/commit/67480503285d4f5019e8cc5429dde82f3e8487d0 measured number of sets or other entities stored by each manager per frame:
Frame duration moving average with 60 frames window size:
A collection to store pending orphaned objects is replaced by
std::vectorbecausestd::listonly gives overhead there. Also a mutex lock to checkstd::vectoremptiness before processing pending orphaned objects is replaced by atomic counting the number of items there. Since this check is performed every frame, potential consistency issues do not matter.Perf profiles:
Before:
With lock:
With atomic: