Provide optimized page-based storage and use it for EFFECT:s
#3660
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.
The patchset contains the following changes:
EFFECT
class, which saves 8 bytes for thesizeof(EFFECT)
for the x86_64 arch.PagedEntityContainer
optimized container, which is page-based and is capable of reusing storage upon erasing and allocating new elements.PagedEntityContainer
to store allEFFECT
instances in the game.The performance impact of this PR is no more than 5-10 FPS difference with current
master
, even for extreme stress-testing cases (tested with 20K effects in the existence at the same time), but the memory allocation patterns are much better, because now memory is allocated in large contiguous chunks, and this memory is aggressively reused when old effects disappear and new effects emerge.This should greatly help to prevent crashes related to memory fragmentation.
It is also expected that when
PROJECTILE
objects will use thePagedEntityContainer
as the backing storage, the performance differences shall accumulate and become much more visible in conjunction.Signed-off-by: Pavel Solodovnikov [email protected]