Parallel Process lag question

I'm doing test plays and I wondered something. Is it safe to assume if my game runs on my computer that most likely anyone else that plays in the future won't have any lag problems? I'm running a few parallel processes.

I'm checking the framerate with F2 and if stays at 60 and below, me and anyone else is good right?
I'm doing test plays and I wondered something. Is it safe to assume if my game runs on my computer that most likely anyone else that plays in the future won't have any lag problems? I'm running a few parallel processes.
It depends on your hardware. If you have a super high end computer, then it might not be the case. The number of parallel events doesn't matter as much as the content of those parallel events when it comes to lag.
Thanks. I heard that it mainly has to do with images that make it run harder right? But what about a few branches and variables?
there is no general answer - a single badly designed parallel process can lag even the most powerfull computer, but even a mediocre computer will have no problems with half a dozen intelligently written parallel processes.
As for the RAM-requirements by images, that also depends on the game - a game with parallax mapping will require a lot more resources for the map background pictures than one with tiled maps.

Additionally, there is an internal cap on the fps to prevent powerfull computers from wasting that power. That means every computer has some reserves to cover some lag, and only if the (additive) lag of everything adds to more than that reserve, the lag becomes visible by dropping the fps below 60.

But that reserve is different depending on the computer, so until you test how much reserves any given computer has, you can't tell if it can run your game.
If your fps is 60 that only means that your computer and every more powerfull computer will have no problems. But when you go to less powerfull computers, you'll never know when the reserve limit is reached and the fps begins to drop.
Thanks. I heard that it mainly has to do with images that make it run harder right? But what about a few branches and variables?
Playing with images can be resource intensive inside a parallel event. If it's just a few branches and variables manipulation (like doing +1 per iteration), it should be fine.

You just have to be aware of how resource intensive is one iteration of the parallel event. Playing with tone/tint of a big picture every frame can be really resource intensive because of all the calculations needed to perform that task. Compare that with a simple +1 for the variable, this is far from being as resource intensive. Even if something like changing the tint of picture is easily done in a regular event, you have to keep in mind that parallel events execute their content once per frame as long as the event conditions are fulfilled.

Now, if you want to have some resource intensive stuff happening inside a parallel event, it is possible to do so by being careful of how you create the event. For example if you have a day/night cycle and want to call a plugin command to stop some BGM/BGS and play another one when the cycle switches from day to night (and vice-versa), you can do it by having 2 switches tracking the cycle. Switch A tracks the cycle and switch B tracks switch A. And you make it so the BGM/BGS changes are only called when Switch A and B are not equal to each other. This will make it so the "resource intensive" task (changing BGM/BGS in this instance, which isn't that resource intensive but let's pretend it is) is only being execute once per cycle change and is not executed once per frame.

The event for the current example would go something like this:
Code:
Switch_A = day_night_cycle // let's say TRUE for day and FALSE for night
if (Switch_A != Switch_B) {
    if (Switch A) { // If DAY
        // Change BGM/BGS for Day
    } else { // If not Day
        // Change BGM/BGS for Night
    }
}
Switch_B = Switch_A

They key is to manage to find a way to make it so only what is necessary is being called and executed on each frame and not to execute stuff for no reason.
Okay, this is helping me to get a better understanding. Thank you. I happen to be test playing with a night and day system and my solution for a different song was to run the map event parallel process event that went like this

Var Region ID = 0 means the map is inside
Var Region ID= 1 means the map is outside

(I found a tutorial for something like this)

I removed the map music from the map properties. And with the one event that also lists the Region ID I ran two music within one branch:

If hour is greater than or equal to 6 with an else branch of if less than 6 to play a different one. But I don't know how taxing that can be?

I don't know how parallels process handles conditional branches. If one is true, play this. If the other is true, play that.

If the branch for greater than or equal to 6 is true, does that mean only that is being executed? And the less than 6 being left alone? Or are both conditions both being constantly checked for and executed?

Sorry if I don't make sense, I have a hard time explaining. Not knowing if it's taxing on the game or not is bugging me. I don't want to pour hours to find out later it's not going to work. ^^;


◆Control Variables:#0230 Region = 1
◆If:Spring is ON
◆Change Tileset:Spring
◆
:End
◆If:Summer is ON
◆Change Tileset: Summer
◆
:End
◆If:Fall is ON
◆Change Tileset: Fall
◆
:End
◆If:Winter is ON
◆Change Tileset: Winter
◆
:End
◆If:Hour ≥ 6
◆Play BGM:Day (90, 100, 0)
◆
:Else
◆If:Hour < 6
◆Play BGM:Night (90, 100, 0)
◆
:End
◆
:End


All I do know is to add wait commands, have switches to turn them off when they are unnecessary or like you said, don't execute commands or stuff for no reason.
I don't know how parallels process handles conditional branches. If one is true, play this. If the other is true, play that.
It handles conditionals the same as non-parallel events. If a condition isn't met, it's not going to execute what is inside the branch, it will just skip it or go to the ELSE branch. However, It will check to see if the condition is fulfilled every frame.

As for your parallel event, it could be optimized with the system I showed you above, since your Play BGM command is being called every frame. But it's not like it's super problematic, playing a BGM itself isn't taxing on the CPU. The game will run just fine. However, issues can start occurring when there are lots of little un-optimized small processes that add up.

Then again, I am a coder that dislike un-optimized system lol, so part of it is also just me trying to make everything too perfect xD.
If you have a parallel process event that does a Tint Screen or Change Weather, and you don't erase it, it could cause your game to lag.

My previous computer, an Asus laptop that was maybe 3-4 years old, used to run MY stuff okay at almost 60fps, but if I downloaded someone's game from here to help them troubleshoot, there were a few occasions where it went right down to 2fps! One had a lighting plugin, and the other had a very big parallel process common event that wasn't well written. I am guessing that those games ran fine on their own machines.

Don't ever think your players will have the same gaming experience as you, especially if you have a good computer.


Just skimming through your event code in your last post ... if this is a parallel process event, how often are those conditions going to change? If not very often, you are going to be constantly telling your game to change the tileset and play the appropriate BGM, when it may already have the correct tileset and be playing the appropriate BGM. For these sorts of things, ideally you would do a check to see if the condition is met AND the desired action has not already happened.
i'd have a wait.X frames line in there. 60 fps X6 conditions to check, thats 360 checks the game is running every second for just that 1 event.
dropping that down with a wait command to only the 6 conditions checked once every 1-5 seconds can have big impact on weaker systems.
Just skimming through your event code in your last post ... if this is a parallel process event, how often are those conditions going to change? If not very often, you are going to be constantly telling your game to change the tileset and play the appropriate BGM, when it may already have the correct tileset and be playing the appropriate BGM. For these sorts of things, ideally you would do a check to see if the condition is met AND the desired action has not already happened.

Not very often. So maybe adding a wait event command of 60 at the end of the event? I'm honestly not sure how long of a wait I should put for any kind of parallel process event.

How do I do a check that condition is met and the desired action has not already happened?

i'd have a wait.X frames line in there. 60 fps X6 conditions to check, thats 360 checks the game is running every second for just that 1 event.
dropping that down with a wait command to only the 6 conditions checked once every 1-5 seconds can have big impact on weaker systems.

Thank you, I will do that. Though I am not sure how long of a wait. Like, is 60 acceptable or 600?

It handles conditionals the same as non-parallel events. If a condition isn't met, it's not going to execute what is inside the branch, it will just skip it or go to the ELSE branch. However, It will check to see if the condition is fulfilled every frame.

As for your parallel event, it could be optimized with the system I showed you above, since your Play BGM command is being called every frame. But it's not like it's super problematic, playing a BGM itself isn't taxing on the CPU. The game will run just fine. However, issues can start occurring when there are lots of little un-optimized small processes that add up.

Then again, I am a coder that dislike un-optimized system lol, so part of it is also just me trying to make everything too perfect xD.

This is good information to know. If I understand correctly, the code you shared is a script or is that actually done with switches? It looks like a one page event or two page event and I'm not sure.

As for being a coder, I appreciate you taking the time to share you wisdom. I am not a coder, unfortunately. That is not my strength but people who can code with ease are amazing to me.



I really appreciate everyone taking the time to comment here. Maybe I sound silly, but this forum here and all the people really are amazing. And Rpg Maker is an awesome product. I know it's just words on the screen but I just like sharing when I'm grateful. 😅

Ps: I don't know why you are called mushroom cake but I finally want to see I like your username. As I like to eat mushrooms and cake but not as one product. xD
@Sakurra
60 should be more than fine for what you are doing.

Mathematically speaking, even a wait command of a single frame will already cut down the amount of checks in half. (Instead of checking every frame, you only check every other frame)

So going with 60 frames of wait should drastically improve the CPU needed.
How are the spring/summer/winter/fall switches being changed, and how is the Hour variable being changed? If they are in a script, then you'll have to just let the parallel common event run with a wait in between each iteration. But if those switches and variables are being changed by another event, then you already know exactly when this common event needs to run - when THAT event makes a change to any of those things.

If that's the case, just add one more command at the end of your event to turn off the switch that triggers it to run, and in the event(s) that change the spring/summer/winter/fall switches, and the one that changes the hour variable, turn the switch on at the same time those are changed.

So the event above won't run at all unless one of those things needs to be changed.
But if those switches and variables are being changed by another event, then you already know exactly when this common event needs to run - when THAT event makes a change to any of those things.


I'm using this tutorial.
So a lot of it is in common events.

But I think I can't turn this common event off without turning off the whole day, month and night system. I think it is okay to leave on?

Right now I'll be adding wait commands to every map that has the event with season tile changes. Think that will suffice?
The event above that handles the change of tileset and BGM - is that a separate event, or part of the larger one?

Original thread: https://forums.rpgmakerweb.com/threads/parallel-process-lag-question.136827/