Page 1 of 2

Performance issue with many entities (fps)

PostPosted: Fri Jan 23, 2015 7:05 pm
by ajm
I've recently purchased a multi-developer license for our team. We're quite happy with the engine's features, documentation and especially the demos. They've been a big help.

We're developing an isometric game that allows players to build their own retail store (add shelves, products, employees etc.) We've been doing some testing and have run into frame rate issues, especially in Internet Explorer.

I've created a small store 20x20 tiles and filled it with shelves. Each shelf is a 1x1 tile entity. To reduce the sprite sheet size each wall is a 1x1 entity as well (see screenshot below). Even with the IgeEntityManager enabled Internet Explorer runs at only 12fps.

Image

I noticed the isometric performance demo runs @ 40fps with 1000 entities on a very large map. However, since the map is large there are only a few entities on screen at a time. when I modified the demo and removed the space between the entities (see below) the frame rate dropped to 1fps.

Image

I thought this may be an issue with the entities intersecting so I added some space between them (see below) but it still only achieved 2fps. This is with no moving entities or animation.

Image

When I reduced the entity count from 1000 to 250 (see below) the frame rate improved but only to 7fps. If you scroll to an empty section of the map the frame rate jumps to 60fps.

Image

We are hoping to have a large store with a number of shelves and animated employees/customers moving around the store. Basically my question is how to increase the frame rate when there is a large number of entities on screen. I'm new to the engine so any tips or tricks for optimization would be great.

I can post links to all of these tests I've run if that helps. Any insight or recommendations would be very appreciated.

Thanks!

Re: Performance issue with many entities (fps)

PostPosted: Mon Feb 02, 2015 4:19 pm
by ajm
I've posted the previously mentioned examples. They can be viewed here:

Store test:
http://devdemo.altervista.org/ige/
14fps in Internet Explorer

Original example:
http://devdemo.altervista.org/ige/ige/examples/15.2-iso-performance-test/
1000 entities @ 30fps in Internet Explorer

Modified example with no space between entities:
http://devdemo.altervista.org/ige/ige/examples/15.2-iso-performance-test2/
1000 entities @ 1fps in Internet Explorer

Re: Performance issue with many entities (fps)

PostPosted: Mon Feb 02, 2015 4:21 pm
by ajm
Sorry, had to break this into two parts due to URL count restriction...

Modified example with even space between entities:
http://devdemo.altervista.org/ige/ige/examples/15.2-iso-performance-test3/
1000 entities @ 1fps in Internet Explorer

Modified example with even space between entities:
http://devdemo.altervista.org/ige/ige/examples/15.2-iso-performance-test4/
250 entities @ 9fps in Internet Explorer

I'm assuming the issue is with drawing or depth sorting the entities. I'm thinking the frame rate will be lower once the characters and pathfinding are added. Is there a "lighter" way to handle walls and static objects that don't move? Any suggestions would be greatly appreciated.

Cheers,

Re: Performance issue with many entities (fps)

PostPosted: Tue Feb 17, 2015 8:42 pm
by robaldred
You're absolutely correct what you're seeing here is the overhead of depth sorting because of so many intersecting objects.
You can control the accuracy of the depth sorting and you can define the 3d geometry to help improve performance.

All entities have the ability to control how their children are depth sorted. Using the depthSortMode() method.
There are 4 modes:
-1 Off, entities will not be depth sorted, sorting can be done manually calling an entities depth() method.
0 Slowest (Highest accuracy) - uses isometric projection and 3d geometry
1 Balanced - uses 3d geometry
2 Fastest (Least accurate) - uses x,y,z position of objects

Code: Select all
entity.depthSortMode(mode);


The default mode (0) is the most accurate but has the biggest hit on performance.
To use depth sorting modes 0 & 1 you will need to define 3d geometry for each child entity, if you don't it wont work.

Code: Select all
childentity.bounds3d(x,y,z);

You can debug this by calling childentity.drawBounds(true);
This will show the aabb of the 3d geometry as a purple cuboid.

Other performance improvements can be achieved by using the IgeEntityManager.
This actively unmounts entites that aren't in view. So their update and render methods are not run.
Just add the Manager to your tileMap

Code: Select all
tileMap.addComponent(IgeEntityManager);


Lastly, if you have a large tileMap/textureMap you will need to section it.
do this by calling autoSection() method

Code: Select all
tileMap.autoSection(20);




On a side note, I'm very surprised how low the FPS is you're getting on IE.
All your examples run at > 10 FPS on my Android phone.

Re: Performance issue with many entities (fps)

PostPosted: Wed Feb 18, 2015 11:07 pm
by ajm
I'm surprised by the performance as well. I'm running on a fairly high end i7 laptop with 16gb of RAM. IE is getting around 1fps and Chrome is 8fps. Thanks for all of the info. I wasn't aware of the -1 option for depthSortMode. I'll try implementing all the methods you've suggested and post my findings.

Thanks again,

Re: Performance issue with many entities (fps)

PostPosted: Wed Feb 18, 2015 11:21 pm
by robaldred
Ok I've just tried your examples on my gaming PC which is top end i7 4770k with GTX980 and I get 6 FPS on IE and 14 on Chrome on this example: http://devdemo.altervista.org/ige/ige/e ... nce-test3/

It is a lot of entities in a small amount of space It's difficult for me to debug without setting up some examples myself, also I notice you're using the trial version which is quite out of date. I'll setup the same example with the premium engine code.

Re: Performance issue with many entities (fps)

PostPosted: Fri Mar 20, 2015 6:32 pm
by ajm
OK, so I've runs some additional tests on performance-test3 with the suggestions proposed. The IgeEntityManager was already implemented and as far as I can tell autoSection is only availabe for IgeTextureMaps. The demo uses a scene with a background pattern for the grass and a tilemap for the buildings so I don't think autoSection can be used here. AutoSection was enabled in the original "store test".

The depth sort mode had been set to 0 which is the slowest. I tried each of the settings in IE:
depthSortMode:
-1 - 13fps
0 - 2fps
1 - 11fps
2 - 13fps

I've left the depthSortMode set @ 2 (on Chrome it runs around 45fps):
http://devdemo.altervista.org/ige/ige/examples/15.2-iso-performance-test3/

The bounds of the entities were set using size3d(x,y,z). The bounds3d method doesn't appear to be available in this version of the engine. The demos are using the "master" branch from Irrelon/ige/ on github. Is this not the premium engine code? My understanding was that the master branch was the stable version of the premium engine and that the dev branch was an unstable leading edge version.

Thanks again,

Re: Performance issue with many entities (fps)

PostPosted: Fri Mar 20, 2015 9:11 pm
by robaldred
Ahh OK.
Hmm it sounds like you're considerably behind engine code wise.
size3d was replaced with bounds3d in December 2013.

If you're using the premium repo you should have all the latest code.
Master was updated from Dev in December 2014 just gone.
Dev is only a few commits ahead and tbh is stable as I'm using it in production with ~20,000 uniques a week.

If you're using > 1 year old engine code you've probably got the old EntityManager too.
It was rewritten and is much more efficient now.

There are considerable changes and performance improvements post 1.4.5
I would consider bring your local copy of the engine source up to date with the repo on Irrelon/ige

Warning though, there are some breaking changes, relating to geometry, pathing, mouse events and tilemaps

Have a read of: viewtopic.php?f=8&t=98 and viewtopic.php?f=8&t=116

All of the optimisations I've made are made to work with 1.5.5 engine code, it's unlikely to function at all with any pre 1.4.5.

Re: Performance issue with many entities (fps)

PostPosted: Tue Mar 24, 2015 5:29 pm
by ajm
I'm relatively new to github and must be doing something wrong. I followed the instructions in the video tutorial and cloned the Master branch to my desktop via the github app. I have tried downloading the latest commit (23 days ago) and the previous version (3 months ago) via the Github desktop app:
Image

It looks like it is still the old version of the engine. When I open the folder in Windows Explorer and run a search on the entire directory the text "bounds3d" is not in any of the files:
Image

I even tried downloading the zip file from the Github site:
Image

But none of the files have any reference to "bounds3d". The only time I can find a reference to "bounds3d" is if I download from the dev branch:
Image

Am I doing something wrong here?

Thanks again,

Re: Performance issue with many entities (fps)

PostPosted: Tue Mar 24, 2015 8:19 pm
by robaldred
Ohh wow, Ok I'm so sorry the master branch was broken by a novice git user before christmas, where the user reverted the code to v1.3.1. It looks like the changes the user made have not be fixed correctly.

The stable master should be at this commit v1.5.5
https://github.com/Irrelon/ige/commit/4 ... fdb2ee60c5

You can checkout that commit directly.