Recognized Lag-Causing Points?

Hello, all--


I was wondering if there were any recognized (or general consensus) points at which the inclusion of any more particular elements (specifically, but not limited to, parallel process events and displayed pictures) will begin to cause lag or other problems to become detectable for the player of a game built with MV.


Say I've got a map with three parallel process events controlling various features... will things start to get laggy if I add a fourth? Or go for ten? Or nineteen?


And if there's no general idea of where the specific breaking points might be, are there any "best practice" rules of thumb for avoiding lag when building event-heavy maps?


Thanks!
It's not the number of parallel process events that's the issue - it's what they do and how well they are designed/written.


A single parallel processing event that contains a loop that doesn't come up for air can cause a lot of lag, while 10 well-written ones could exist very happily together on the same map.  Events that set up map stuff - tints, show picture, weather, should usually do an Erase Event after all the setup stuff is done.  You might not see a difference if it's not erased and continues to run while you're on the map, but it uses processing power.


If you do have a parallel process that has to run the entire time you're on the map (for instance, to check the location of the player or the region they're on for some reason), don't put a loop right near the start and a repeat right near the end, as they repeat by default, and add a Wait for X number of frames each iteration - consider how many times you need to check something every second.  If it's player position, they'll likely only cover a few tiles in a second, so a wait of 10 frames would still let it check with each tile movement. If it's a keypress, you'd probably want to check a lot more frequently.


There are really no hard and fast rules - if you find something is lagging, it's a matter of finding out what might be causing it, and if it's a parallel process event, figuring out how it could be better designed to achieve what it needs to do without the lag.
 so a wait of 10 frames would still let it check with each tile movement.



This is really essential. Always wait 10 fps! It helps a lot! 🙂
Something that will cause lag (especially when deploying to mobiles with their lower capacities) is using large parallaxes for the map. Tilesets have been invented for a reason, a map based on a tileset uses up only a fraction of the memory needed for full-size pictures or large parallax maps. (as a mathematical estimate, we're talking about a factor of 5000 here - a parallaxed map will need about five thousand times the memory of a tileset map).


That can be handled for small parallaxed maps, but don't try to make large parallaxes as that uses up memory very fast.


About the waits: don't freeze your brain on exactly 10 waits - the optimum number of waits depends not only on the parallel process and its functions, but also on the game and the map. In a parallel process, the wait command basically tells the engine: skip execution for the next X frames.


Too few waits, and the parallel process runs more often than neccessary, creating real lag.


Too many waits, and the parallel process will not check its function often enough, appearing to be hampered (pseudo-lag).


But it has been tested that several independent parallel processes use up more resources than a single parallel checking for all the same options.
Cool! This is all extremely useful stuff. Thanks, everyone.
You know, that "factor of five thousand" thing, in particular, bends my brain (because I had just learned the full joys of using parallaxes as floors and was dreaming of all the lovely Photoshoppery I could unleash). So I'm curious-- is there a certain map size (in RPGMaker tiles) that you'd begin to call "too large" for reasonable use of parallax?


Thanks very much-- this is helping immensely even when it's a harsh reality check.
@Magnificent Brain Candy not really, because it depends on the computers.


If you plan to deploy to mobile, don't use parallaxes greater than screen size (all devices can handle pictures of their full screen size, the problem starts with maps that are multiple screen sizes because the other parts are not visible but still need to be processed as part of one picture).


For a full capacity desktop computer, the numbers are better due to much more RAM and the option of virtual memory, but it also depends on which target computers you want to run your game on. If you limit yourself to high-end-computers, there should be no problem with a parallax map of 50x50 or 100x100, but if you want the game to run on older computers as well that will stress it. A lot of people restrict parallaxes to screen size or a little bit more on older desktops as well.


As for the mathematics:


In tiles, each map position needs one tile number (usually one Byte) for each map layer (plus some overhead for storing the tileset itself, but that is not too much).


In parallax mapping, each pixel needs its own color data (24 bit color = 3 Bytes per pixel), and there are 48x48 pixels on each map tile for MV. Again, that is per layer.


Tilemaps in MV have three layers, parallaxing usually uses two layer - just do the math.


And don't confuse file size for downloading with this picture size - yes, pictures can be compressed to a fraction of this data for storing and downloading, but the active map needs to be worked on - it cannot be compressed when being worked on.


So in the device RAM while playing it will always take full size.

Original thread: https://forums.rpgmakerweb.com/threads/recognized-lag-causing-points.73592/