Legacy GM huge FPS drop whenever I do 'dash' in a huge room.

jobjorgos

Member
Hi!

In my game, I have always 30 FPS (equal to room speed). But whenever I use 'dash' in a big room, there is a huge lag spike. The FPS drops to 14-19 while the dash is active.
The dash does the usual run speed x15 for 20 steps + plays a wind sound and then resets back to usual run speed.
I have a view of 1024x768. And in rooms of 1024x768 or 2048x768 there is no problem at all.

But in the rooms where the sizes are 3072x3072 and 2948x1536 this problems occurs.

I dont have crazy much objects in the room, but just to be sure I made it so that all objects that are outside the view area are disabled.

I have a very good new MSI laptop with 16GB ram 7th gen i5 and gtx 1060 3GB video memory card.

So I don't know if the FPS drop is causes to too much ram memory, too much video memory or something else?
 
M

maratae

Guest
Hi!

In my game, I have always 30 FPS (equal to room speed). But whenever I use 'dash' in a big room, there is a huge lag spike. The FPS drops to 14-19 while the dash is active.
The dash does the usual run speed x15 for 20 steps + plays a wind sound and then resets back to usual run speed.
I have a view of 1024x768. And in rooms of 1024x768 or 2048x768 there is no problem at all.

But in the rooms where the sizes are 3072x3072 and 2948x1536 this problems occurs.

I dont have crazy much objects in the room, but just to be sure I made it so that all objects that are outside the view area are disabled.

I have a very good new MSI laptop with 16GB ram 7th gen i5 and gtx 1060 3GB video memory card.

So I don't know if the FPS drop is causes to too much ram memory, too much video memory or something else?
Have you checked your task manager?
Have you used the GMS Profiler?
My guess is that it's probably something on the dash code.
 
W

Wraithious

Guest
I'm wondering, are you drawing the backgrounds in a for loop? if so then the added background size limit you showed
But in the rooms where the sizes are 3072x3072 and 2948x1536 this problems occurs.
if being drawn repeatedly could reach a point of overload
 

JackTurbo

Member
My gut feeling is that the lag spikes are probably due to the way your activating and deactivating instances.

Activating and deactivating instances is a relatively costly thing to do and if your view is moving quickly and your doing this every frame, then that could be the cause. Without more details though I couldn't really be sure.
 

jobjorgos

Member
Have you checked your task manager?
Have you used the GMS Profiler?
My guess is that it's probably something on the dash code.
ah that are some good ideas to try out!
I tried out task manager and it seems there is no memory/processor/ram or whatever overload. Everthing is at 5-10% and ram memomry used is just 115MB at the moment when I do a dash.
I did not even knew about the profiler in debug mode. I just tried it out and it gave the following result:


I dont know the meaning of these percentages yet so I gonna do some research into them to learn if these numbers are good or bad.

And I think nothing of the dash code is causing any troubles. Here is how the dashing is be done:
 

jobjorgos

Member
My gut feeling is that the lag spikes are probably due to the way your activating and deactivating instances.

Activating and deactivating instances is a relatively costly thing to do and if your view is moving quickly and your doing this every frame, then that could be the cause. Without more details though I couldn't really be sure.
Yeah I already did that it checks only once every 15 steps or so so it would not overload in memory.
 

jobjorgos

Member
I'm wondering, are you drawing the backgrounds in a for loop? if so then the added background size limit you showed

if being drawn repeatedly could reach a point of overload
nah im not drawing any background inside a code. I just did it in the room editior window, it is a 64x64 grass background that repeats.

I just did a run test without background and not any influence it seems.
 
I

icuurd12b42

Guest
the first thing that comes to mind is if you are activating and deactivating instances outside the view... running fast would cause that code to trigger a lot of instances to switch in and out of the activated/deactivated list and lag
 

jobjorgos

Member
the first thing that comes to mind is if you are activating and deactivating instances outside the view... running fast would cause that code to trigger a lot of instances to switch in and out of the activated/deactivated list and lag
Well even if I completely remove the object that does all the activate/deactive work, it does the same FPS drop while player is dashing.
What I find strange is that I get a FPS drop while not any of my computer powers are overloaded. no CPU, GPU or any other part of my computer is overloaded on task manager while dashing in the game. They are all 0%-20% of the total powers.
Does might game maker limit the availiable CPU/GPU used for the game?

Also it is known of surface_create that it does alot of GPU, I tried to deactivate the draw surface object, but it didnt had any influence at all.
 
I

icuurd12b42

Guest
so what happens more when you dash. more bullets or more instance_create calls? that could be the reason too
 

jobjorgos

Member
I just tried alot of things the past days, and finaly I got much closer to the cause of the problem.

I just tried removing like 200-300 tree/plant/stone objects from the room, and then I just had 30 FPS all the time while dashing in the game.

So what I have to find the answer on now is:

Is there a chance deactivating objects is not good enough and I should destroy them instead and recreate them when my camera gets there?

How can a room with about 500 objects in total cause lag at all? It is just a 2D game with 500 objects with an avarage of about 70px by 70px images. I think it would not even cost 1GB of memory. The only code they have is
Create:
height = 30; //(used so the player cannot walk straight towards a tree, but if player is height 30 or higher then the player can jump/ walk over it
depth = -y;
 
I

icuurd12b42

Guest
>Is there a chance deactivating objects is not good enough and I should destroy them instead and recreate them when my camera gets there?
Likely not, creating instances is one of the most expensive thing in gm

>How can a room with about 500 objects in total cause lag at all?
Because you are doing this in the step I bet
>depth = -y;

remove that and see what happens...

the moment you change the depth of an instance, all instances are resorted. it is also one of the worst thing to do in game maker
 

jobjorgos

Member
the moment you change the depth of an instance, all instances are resorted. it is also one of the worst thing to do in game maker
This is interesting. I have alot of objects having depth = -y; or depth = -bbox_bottom; (in create, but in step also)
And I tested my game on my friends 10 year old crappy computer and it was even almost unplayable there with 5 FPS avarage.
Really have to make alot of things more effecient it seems... thanks for thinkink along with me anyways
 
I

icuurd12b42

Guest
did you try removing that depth=-y line though?

See my reply to wolfy on how I bypass this problem
urgh the forum changes the [ link ] tag to a video. (@Nocturne forum bug)

 

jobjorgos

Member
did you try removing that depth=-y line though?
Yep I did so but didn't see a noticable change really :(

Afterall I brough the FPS to an acceptable, but not perfect FPS, by making the list of disabled objects way bigger, by not just disabling Environment objects but just any kind of objects that dont require to be active when you dont see them. I should keep the number of instances active at the same time below about 500. From that amount the FPS will drop very fast I noticed in playtests.

Nice to see how you can have up to 7000 creatures in that video before the FPS started to drop. Probly in the case of your video there is less code and having smaller sprites probly makes the difference with my case of max 500 instances.
 
T

Thunder Lion

Guest
Hi!

In my game, I have always 30 FPS (equal to room speed). But whenever I use 'dash' in a big room, there is a huge lag spike. The FPS drops to 14-19 while the dash is active.
The dash does the usual run speed x15 for 20 steps + plays a wind sound and then resets back to usual run speed.
I have a view of 1024x768. And in rooms of 1024x768 or 2048x768 there is no problem at all.

But in the rooms where the sizes are 3072x3072 and 2948x1536 this problems occurs.

I dont have crazy much objects in the room, but just to be sure I made it so that all objects that are outside the view area are disabled.

I have a very good new MSI laptop with 16GB ram 7th gen i5 and gtx 1060 3GB video memory card.

So I don't know if the FPS drop is causes to too much ram memory, too much video memory or something else?
I think maybe the sound file is the issue? Or potentially a lot of activation and deactivation or even too many effects.
 
T

Thunder Lion

Guest
Yep I did so but didn't see a noticable change really :(

Afterall I brough the FPS to an acceptable, but not perfect FPS, by making the list of disabled objects way bigger, by not just disabling Environment objects but just any kind of objects that dont require to be active when you dont see them. I should keep the number of instances active at the same time below about 500. From that amount the FPS will drop very fast I noticed in playtests.

Nice to see how you can have up to 7000 creatures in that video before the FPS started to drop. Probly in the case of your video there is less code and having smaller sprites probly makes the difference with my case of max 500 instances.
Hey I may be right lol! Hey this is a solution reduce the dash speed and time. Also make the view 32x32 less pixels but also have the game use vertex processing. Also try using parenting if you have not it will save a lot of memory sense each single object won't have to have their own collision code.
 
T

Thunder Lion

Guest
I just tried alot of things the past days, and finaly I got much closer to the cause of the problem.

I just tried removing like 200-300 tree/plant/stone objects from the room, and then I just had 30 FPS all the time while dashing in the game.

So what I have to find the answer on now is:

Is there a chance deactivating objects is not good enough and I should destroy them instead and recreate them when my camera gets there?

How can a room with about 500 objects in total cause lag at all? It is just a 2D game with 500 objects with an avarage of about 70px by 70px images. I think it would not even cost 1GB of memory. The only code they have is
Create:
height = 30; //(used so the player cannot walk straight towards a tree, but if player is height 30 or higher then the player can jump/ walk over it
depth = -y;
Try using tiles instead of sprites for images in the map where applicable. Instead for them use a simple invisible block to create a wall.
 
M

Matt Hawkins

Guest
It looks like you have way too many instances running.
Are all the weapon instances necessary?
 

jobjorgos

Member
Hey I may be right lol! Hey this is a solution reduce the dash speed and time. Also make the view 32x32 less pixels but also have the game use vertex processing.
Well reducing the dash speed and time does indeed work and making the FPS way faster, but I really want the dash to be the same as it is now, or it will not be effective enough for the gameplay.
Tried out vertrex processing like you said, but it showed strange flickering sprites + didnot lower the FPS. Aswell I tried out at Vetrex Buffer Method to select 'fast' instead of compatible like I had before, and no influence on the FPS aswell.

Also try using parenting if you have not it will save a lot of memory sense each single object won't have to have their own collision code.
Oh that sounds are a very good idea! That might will help alot, I will try that out.

Try using tiles instead of sprites for images in the map where applicable. Instead for them use a simple invisible block to create a wall.
Yeh I already using tiles, and using invisible walls where it is possible on those tiles.
 

jobjorgos

Member
It looks like you have way too many instances running.
Are all the weapon instances necessary?
Acctually the weapon instances are not necessary to be active all the time, since they are on the top in the debug compiler I gonna try aswell to turn them off while they are not needed.

Thanks alot everyone for all the advise, time for me now to try it out!
 
Top