Is it safe to spawn many disposable slices of limited lifetime or some kind of management strategy is required?


If I have a slice made by various entities and components with a limited lifetime and that can be spawned at hi rate , but with just a limited number of them active at a time, do I have to implement a specific solution(es pooling) or the engine employ a general solution that manages this kind of scenario in a sustainable way?

Both gameplay replicated elements ( projectiles , pickups,human and AI enemies) and temporary clientside fx like particles , sounds, decals , dead enemies , broken pieces and other physical debris.

How much is too much as dynamic spawning is concerned?

Imagine an .io kind of game where a server needs to run for a very long time.

Are there known point of failure that can limit the use of simple and naive implementations?

If some strategy is required are there engine specific best pratices for optimal ( memory/performance/ease of implementation) that better fit the engine design in this kind of scenario?

asked 6 years ago8 views
5 Answers
Accepted Answer

Hi Gamely,

In general, Entity Component Slices use reference counting to keep track of asset use. That reference count (as you may expect) is adjusted per every usage of the asset with the asset being unloaded at a ref count of 0. There are some legacy systems however where assets aren't freed until the level is unloaded. We hope to address this in a future version so keep your eyes peeled for that. Past that, I think implementing a pooling system would be a great idea depending on the quantity of slices you're spawning.

I would also recommend checking out the Multiplayer Sample included with Lumberyard. It's a good example of spawning a good number of a variety of slices. It does not use pooling so it may help you get an idea of bounds.

Please let us know if you have further questions here!

answered 6 years ago


answered 6 years ago

Thanks for your answer.

Hope to have some free time to test something live.

I will surely take a deep look at multiplayer sample.

I need to inspect the code as every single sentence makes more question arise.

I want to understand if the reference to a slice in spawn component make the slice and referenced resources load or not and if there a way to defer the loading and/or to preload to better control what is loaded at any time.

what about assets from server point of view?what get loaded in the server and how to lighten the server package to remove client only assets or load simplified version of some assets(es model with just collision, more compressed animation with less bones etc.

The idea here is always to maximize how much a single instance can manage to load less things , faster and more efficiently to not waste/trash memory and not degrade performances over time.It can be labeled as an early optimization, but even in the beginning is always better to make well informed choices so need to grasp all the engine fundamentals.

Also allocators are an insteresting subject I would love if you can document further.

answered 6 years ago

On the subject of resource loading timing, we're actively looking at that. Presently you can try playing with AZ::Data::AssetFlags values to manipulate the timing of loads as it pertains to an instance of a slice. OBJECTSTREAM_QUEUE_LOAD should allow a slice to load while a loading asset is still being loaded while OBJECTSTREAM_PRE_LOAD should hold the slice until the loading asset finishes.

On the subject of assets from the server point of view, I will have to do some follow up to get a clearer answer. What I do know is that we have a NULL Renderer exactly so we don't waste resources rendering when there isn't anywhere to display to. You can also control what fields are synchronized over the network so you don't have to synchronize every field of an entity.

Can you let me know what you'd like to see in regards to allocators?

answered 6 years ago

Thanks I will look at that flags.

About allocators I use to have few custom ones i use the most in my other project and I have just seen that there are just various ones in the engine, but there is no documentation and is still not clear to me how to make use of them.

However main priority is still the doxygen like documentation and github to make studing the source way more comfortable that stick to the pc and visual studio.

answered 6 years ago

Adding new answers, comments, and votes is disabled.