Performance Issue on Different Machines

I have read a couple of questions that tackle the same issue, but unfortunately, i couldn’ t solve my my problem. This major issue for me after going far in using defold. I hope you can assist me.

I have a desktop with i7 & GTX680, and i have a laptop with i3 & Intel HD Graphics (not sure what series, but its kinda old 2010). When i run my game on the desktop, its fast and everything is works great. When i run it on my laptop, its slow, and the jumping reaches the ceiling of my level, and most importantly, collision doesn’t work properly as i keep falling through it.

Please note that FPS is set to 60 and variable_dt is checked. Also, i have tried to install the latest driver on my laptop, but same issue. I even tried to deploy on my mobile, but i had the same issues.

Desktop

Laptop

First, i tried to compare to dt variable. In desktop, i got an average value of 0.016499999910593, and in the laptop i got an average value of 0.050044998526573.

Second, i tried to run the debugger which displays several statistics on screen. For the desktop, i got a locked 17 fps, but for the laptop, i got an average of 40 fps.

Third, i ran the web profiler. Below are my results:

Desktop


Laptop


Can anyone please assist me on what is happening here? Is it that my code optimization? What am i doing wrong?

1 Like

Just looking at the profiler it seems that the majority of the time in the frame is spent in the physics engine updating the simulation. Are you using a lot of physics objects for collision? That might explain why the performance is fine on your desktop but not on your laptop.

1 Like

If you haven’t read them already there are some interesting stuff here Know your engine limitations! and here Draw calls and Defold and to a lesser extent here Texture Management in Defold

I don’t think the graphics are the problem but the CPU. Actually, looking a bit closer your render script does take a long time on your laptop.

Your rendering doesn’t seem to take a lot of time, but how many draw calls do you have?

What does seem to take a lot of time is the physics, the games I have worked on have barely used any physics so the only pointer I have here is to try to use static objects as opposed to Dynamic and Kinematic, of course try to keep collision objects to a minimum.

It does look like you do quite a bit in update loops, for this kind of game it is inevitable, but try to update positions and such with the engine and C (go.animate) and not the in LUA as mentioned in the first link of this post.

1 Like

Woah!

  1. Did you profile using the latest update for Defold Editor 2? There was a bug before that with the profiler.

  2. The Vsync is waiting for a long time. Anyone got any explanation why?

  3. Seems that physics is taking long time. Are you using tiles or game objects that masquerade as tiles?

  4. Same with the GameObject context. There’s some serious processing going in there. Are you using a camera component or are you moving the world around the hero?

  5. The values seem somewhat similar between desktop and laptop except the point below.

  6. On the laptop due to the integrated graphics it’s taking 50+ ms to process the rendering. I think that’s where the huge difference first comes from. I have no idea where to even start optimizing this in Defold.

Thank you guys for the best community ever. Thanks to your info, i was able to optimize my game. I was able to reduce the 137ms to 68ms when there is enemy collision with the player and to 35ms without enemy collision.

Here is what i did:

  • I noticed that in my level design, i had some outliers tiles to close my level. I think this was the main problem. I immediately removed those tiles and created a 2048x2048 background image, and add that. This gave me a big difference in performance.

  • I revised my whole code and removed most of the go.get_position() functions, and replaced them with a self property.

  • whenever there was an arithmetic operations that involves vectors, i altered the code to make it on the x/y coordinate level.

I tried to optimize the code more and remove the msg.post that i use for sprite animation, but i didn’t know how to use go.animate with atlas animation groups.

Doing all that gave me a incredible boost in the performance. It seems we have to start development on weak machine to make sure that conformance is good, otherwise, it maybe too late to start optimizing when going vise versa.

Again, a million thanks to everyone.

5 Likes

It’s great that you managed to increase performance, but the numbers are still not very good. Could you please provide some additional information:

  1. How many game objects do you have? From the screenshot it looks like only 9 (Instances under Counter)
  2. What kind of physics objects do you have? I’m guessing Kinematic for the player character and enemies? What about others?
  3. What’s the size of the tilemap?
  4. What does the Draw Calls Counter say? You’re spending a lot of time rendering.

You should have a solid 60 FPS, especially on your desktop PC.

What are the good numbers? Is there like a benchmark or something that i can use to make sure that i am good all the way?

I have 5 enemies that i spawn. Also, i have 14 animated tiles (sprites) that i spawn (they don’t have collision).

All my physics type are Kinematic. I have 5 enemy objects, not sure if tiles counts too.

I have tried disabling vsync from the nvidia control panel, but still the same.

The ingame profiler shows that you have 60fps.

Coming back to my first question: are you using an up to date Defold Editor 2?

Where does it say 60fps. In the ingame profiler, it says Frame: 16 Max 24, or do you mean the number of messages?

On my desktop PC, i am using Defold Editor 2. In my laptop, i am using Defold Editor 1, because the new editor is heavy and my laptop starts lagging when using it.

The Frame numbers are in ms so it’s 60 fps in the current frame and you had minimum (Max ms) 40 fps.

Hi,

You have hybrid video card on Laptop? If you have hybrid, try enable use discreet video card always. I have same problem.