r/cpp • u/pavel_v • May 06 '26
What makes a game tick? Special Issue - Buffy the Performance Slayer · Mathieu Ropert
https://mropert.github.io/2026/05/05/making_games_tick_buffy_special/
52
Upvotes
21
u/Untelo May 06 '26
In the past I've implemented a stats system for a game mod project, so I was eager to hear of different architectures being discussed. The article started out super interesting, but I felt it fell flat by focusing on container selection instead of investigating entirely different approaches to representing stats. I'm sure the author could have provided a much more unique perspective on that topic.
3
u/TheDetailsMatterNow May 06 '26
Should have the equivalent functions. It's not made to be a drop in replacement for unordered_map. It's meant to follow the engine's standard, including it's style guide and reflection processing.
You're going to find 3rd party alternatives faster because unordered_map is ABI locked and can't use recent techniques internally.
4
u/groshh May 06 '26
I dislike how you went to unreal types but then mixed them with std::pair
if you're going to use Unreal types use TArray with TPair/TTuple
2
u/Sopel97 May 06 '26 edited May 06 '26
Ok article, but I feel like a lot of unknowns is left out by the possibly terrible update function, as mentioned here
At the very least it adds a ton of allocations as the temporary stats are accumulated, duplicating already existing entries. Optimizing the data structures for shitty code feels kinda off and I really dislike the last version with a variant for this reason
Solid article otherwise, even if limited in scope.
2
u/SuperV1234 https://romeo.training | C++ Mentoring & Consulting May 06 '26
Very good writeup. One could argue that the entire system could have been designed with a more data-oriented mindset from the get-go, but I think that the improvements and research you've presented make a lot of sense if a large redesign is not an option.
2
u/grishavanika May 06 '26
Unsure this is the main win. The main difference is that TArray assumes the elements are relocatable: so realloc/memcpy is used under the hood without having a need to do per-element move on resize.
2
u/donalmacc Game Developer May 06 '26
Given this is an Unreal game, I'd love to see the speedups with TMap. I realise the API isn't the same, but the containers are generally quicker for standard game use.
2
u/matthieum May 06 '26
I'm very curious about
TInlineAllocator.AFAIK,
std::allocatordoes NOT allow an actual inline allocator implementation, since moving the allocator will then result in dangling pointers.What's the trick behind
TInlineAllocator?