Sign in to follow this  
WizEric

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?

 

Thank you in advance.

Eric

Edited by WizEric

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this