Skip to content
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

Provide optimized page-based storage and use it for EFFECT:s #3660

Merged
merged 3 commits into from
Mar 3, 2024

Conversation

ManManson
Copy link
Member

The patchset contains the following changes:

  • Reordering of data members in EFFECT class, which saves 8 bytes for the sizeof(EFFECT) for the x86_64 arch.
  • Add PagedEntityContainer optimized container, which is page-based and is capable of reusing storage upon erasing and allocating new elements.
  • Use PagedEntityContainer to store all EFFECT 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 the PagedEntityContainer as the backing storage, the performance differences shall accumulate and become much more visible in conjunction.

Signed-off-by: Pavel Solodovnikov [email protected]

@past-due past-due force-pushed the paged_entity_container branch from e1905de to 93db3e8 Compare February 28, 2024 20:46
This decreases the overall `sizeof(EFFECT)`
from 96 to 88 when tested on Windows x86_64 build.

Signed-off-by: Pavel Solodovnikov <[email protected]>
…-game entities

`PagedEntityContainer` is an optimized page-based
container for various in-game entities, capable of
recycling erased elements, which greatly reduces
memory fragmentation for rapidallocation/deallocation
patterns.

Signed-off-by: Pavel Solodovnikov <[email protected]>
@past-due past-due force-pushed the paged_entity_container branch from 93db3e8 to 1f5cfee Compare February 28, 2024 23:25
@past-due past-due self-requested a review March 2, 2024 22:30
@past-due past-due merged commit 6186e8d into Warzone2100:master Mar 3, 2024
38 checks passed
@ManManson ManManson deleted the paged_entity_container branch March 3, 2024 16:37
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.

2 participants