Slow down: Artemis C++ Port & SDL 2

Recommended Posts

Hello there!

I currently have an issue with the Artemis C++ port (https://github.com/vinova/Artemis-Cpp) with SDL 2.0.

After having created an amount of effects the game starts to slow down and the frame-rate goes high.

In my current projects there is an effect system that creates lots of particles for explosions etc.

These particles have a defined age, so they "die" after a short time. I have set the following:

if (age < 0.0f) { e.remove; }

so that the created particle (= entity) with all components and systems is automatically removed.

This seems to work. But why does it slow down after a while? I don't see any leak. Maybe somebody experienced the same thing?

Eric

Edited by WizEric

Share on other sites

hi,

I'm using artemis-cpp as well. In my case, if the number of entities passes a certain threshold the app starts slowing down. This is on a 4th gen i5 with gtx 860m. I suspect its due to the fact this implementation does not have a proper struct of array approach. Check the addcomponent function in entitymanager.cpp file, in that you can clearly see they use a Bag<component *>. A bag itself defines its array like E *data, where E can be any type. Effectively, you get

Bag<component *> components;
// which, inside entitymanager, translates to
component **data;


See? Its an array of pointers (EDIT: Its not a technically an array of pointers but a pointer to a pointer. I said array because later its allocated and used as a normal array). Now I may be completely off here but it looks to me that this causes the code to jump around when accessing these pointers, which is what the AoS approach aims to solve. I'm at work so can't try it, but IMO using an array of plain data instead of array of pointers might help.

EDIT2: A bit offtopic, but you can get rid of that if statement by using a delayedEntityProcessingSystem to get rid of branches

Edited by SpaceRoach

Create an account

Register a new account

• Forum Statistics

• Total Topics
628308
• Total Posts
2981979

• 9
• 9
• 13
• 11
• 12