v3.7 speed compared with 3.6

I have a game in development.
I build it with cocos2d-x-3.6
It runs on an iPad 1 at 60fps

I build it with cocos2d-x-3.7 (latest from github)
It runs on an iPad 1 at 45fps

Should I be worried - or is the github latest not yet optimised?

(I’m only testing on the iPad1 as a worst-case scenario, of course, but still - a 25% drop in performance…)

2 Likes

Can you use Instruments and profile both versions? That would be quite useful in tracking down the performance degradation.

I’m an Instruments noob - but gave it a go and there’s nothing I can put my finger on in the output that points to a particular problem - although I think that’s down to me not finding it rather than it not being there.

Of course it’s really difficult to measure twice at exactly the same point in the game - so in one case there may be more baddies around, which obviously makes for a poor comparison.

Any suggestions?

Hmm this is actually quite weird.
Just for confirmation have you tested it against other platforms?

I don’t really have much advice I’m afraid. I’ve just used Time Profiler on my game in development and pretty much the only method I could see in the call stack that was mine was main and everything else was the system.

It’s a bit of an art, but I was hoping you’d be able to see some comparison between the two.

Well, bearing in mind the only thing being changed is the version of cocos, it should be a system function that is making the change!
Main will encompass all of your methods - so if the game is performing worse, then the performance will be reflected in main, surely?
What I need to find is which of the cocos functions has changed to slow down the overall performance?

OK,
I went back to first principals.

Create a new project for 3.6 and one for 3.7
Just change the HelloWorldCScene.cpp to create 100 sprites instead of one

    for (int i = 0;i<100;i++)
    {
        auto sprite = Sprite::create("HelloWorld.png");

        // position the sprite on the center of the screen
        sprite->setPosition(Vec2(i, visibleSize.height/2 + origin.y));

        // add the sprite as a child to this layer
        this->addChild(sprite, 0);
    }

ON an iPad 1

Running with 3.6 gives GL Verts 672, GL Calls 3, Fps about 17.5
Running with 3.7 gives GL Verts 672, GL Calls 3, FPS about 11 - 13

Interestingly the 3.7 seems to flick between 11.8 and 12.8

At 50 sprites,
3.7 gives 26 fps
3.6 gives 36 fps

So drawing a sprite seems to be considerably less efficient in 3.7!

Could anyone comment on this (i.e. do you get the same results?)

Tried on iPhone 4 too with 50 sprites

3.6 gives 37 fps
3.7 gves 38 fps

So almost identical with 3.7 being more efficient if anything!

ON iPhone 5c with 200 sprites

3.6 gives 60 fps
3.7 gives 47 fps

So I’m confused now - anyone have any ideas?

When I said System functions, I meant iOS methods, not cocos2d-x methods, so I wasn’t even able to get a bearing on where to start looking.

After much looking, I don’t have much of an idea either (see my amended post above)

But it does look like drawSprite has different functionality (the new triangle stuff perhaps?) which maybe is actually less efficient ?

Those figures seem terrible for something so simple. What are you running the program on to get 17.5 FPS?

This actually is really really terrible. Guess I am sticking with 3.6 unless this is sorted out.

Yeah - my tests were with the straight-out-of-git code - so I am hoping there’s stuff in there that just hasn’t been tested yet - I will maybe try with RC0 if I get a chance!

Sorry - that got lost in the editing! I"ve amended the post now.

the low figures were on an iPad 1

What happens on iPhone 4 with more sprites (like 100 or 200)?

Because in all other situations it looks like 3.7 is a huge performance hit, bad enough for me to refrain from upgrading to 3.7 until this has been resolved…

Thanks for letting us know!

You are literally not going to believe this:

cocos2d-3.6 running on iPhone 4

Sprites          FPS                FPS
300              60                28-47
200               7.8               7.3
100              17.5              17.1
50               35                38
5                60                60

It looks like once it gets slow enough the fps reporting on screen is just wrong; got 300 sprites its shows as 5fps in XCode but 60 fps on screen!

Curiouser and curiouser!

So…this is a bug with v3.7?

Ah, so the FPS values you were talking about were taken from the Xcode Debug Gauges and not from the on-screen FPS display?

I am using 3.7rc0 with a side scrolling racing game with chipmunk physics set to update with 3 substeps, a 1024x1024 sprite sheet for a background parallax, and a 1024x1024 sprite sheet with about 20 sprites for the character and world objects, and I have not seen any drop much below 60 fps on Nexus 7, Nexus 9, Galaxy S5, iPhone 5, iPad Mini Retina.

@Maxxx, can you share a test project with assets?

Cocos2d-x render pipeline is getting slower and slower, and this due to the 3d features, and yeah, disable Sprite Clipping this well give your benchmarks a little boost… Look in a header file named “ccConfig.h”…

Me neither, i’ve switched my project to 3.7rc0 and haven’t seen any degradation in performance. My game is quite big, with 3d objects and scenes, custom meshes, heavy use of shaders, particles, physics and a lot of sprites. On iOS devices (4s+ and iPad2+) FPS is 60 and on low end Android devices is around 50-60 (mid and high are always at 60).