Event performance optimisation

Hello.

RMMZ, v1.6.0

So I'm having issues finding information on event performance. I know the game I'm creating will end up being pretty large, and I'm doing various stuff to curb performance hits. But when it comes to events, I'm having trouble figuring out how to optimise events to minimise the performance hit.
For example, I made a test map and pasted around 80 completely empty events. Specifically: disable walking, priority at above characters and trigger as action button + it is without any image. The performance hit is extremely large down to max 30fps from my usual max 150 (I've limited my frames to be max 150).

Do I expect to have 80 events on one map? I think my other attempts at curbing performance hits will have me avoid getting the number of events on one map that high, but even a smaller amount of events can have an effect on performance that is more than I'd like. How do I optimise it? If I make them erase themselves via an autorun, it does run better after the initial hiccup when transferring to the map. However, even when all of them are erased, there's too big of a performance hit from around 150fps to 100fps. This is more important on weaker systems, of course.

I'm just looking for any information on how to minimise the performance hit from events, and optimise anything regarding said events. Tips and tricks... anything.

Thank you in advance!
80 empty events shouldn't tank your FPS that hard under normal circumstances. Are you using any plugins? Or do you have any parallel events that are constantly trying to poll all the events on the map for some reason or another?
You should not have seen a performance impact like that from empty events.

I am going to suggest you have something else interacting with your system because I did the exact same thing (empty map with only one transfer event) and a second map with 80 empty events and my FPS went from 145 to...145.

It's also worth mentioning that nothing in RPG Maker works or displays faster than 60 FPS, so it really doesn't matter if you're optimized to any number higher than that because the player won't see the difference (unless you're also modding the heck out of the engine).
As @Arthran said there must be parallel event (check also common events) or some plugin that causes that.

I tested map with 200 events stepping animation on etc... No impact on FPS at all.
80 empty events shouldn't tank your FPS that hard under normal circumstances. Are you using any plugins? Or do you have any parallel events that are constantly trying to poll all the events on the map for some reason or another?
You should not have seen a performance impact like that from empty events.

I am going to suggest you have something else interacting with your system because I did the exact same thing (empty map with only one transfer event) and a second map with 80 empty events and my FPS went from 145 to...145.

It's also worth mentioning that nothing in RPG Maker works or displays faster than 60 FPS, so it really doesn't matter if you're optimized to any number higher than that because the player won't see the difference (unless you're also modding the heck out of the engine).
As @Arthran said there must be parallel event (check also common events) or some plugin that causes that.

I tested map with 200 events stepping animation on etc... No impact on FPS at all.
You're all of course right! I immediately located that the issue is VisuStella's Events & Movement Core plugin. I made the classic mistake of going so far down the rabbit hole I forgot to check the basics.
I really do require this plugin however, so I suppose I'll have to see if it's possible to make it run a bit better with certain settings changed - unlikely I would think. But anyway.

Thanks for the help.
VisuStella Events and Movement Core actually does drastically reduce the maximum number of events that you can have on the map at the same time, but it still shouldn't be quite as bad as you're describing.

I did a test back in July, where I used Events and Movement Core to continuously spawn events (they did have a sprite... but no animation, movement route, or event commands) until my FPS dropped below 30. Using Events and Movement Core, I was able to spawn 473 events before my FPS dropped below 30. Since I was using a sprite, and you're not, I would expect that your results should be better than mine... plus my PC is kinda old. I would have been using slightly older versions of MZ and the plugin back then though, so I guess it's possible that something has changed since then.

Events and Movement Core definitely does cause problems though, because when I tried the same test using Galv's Event Spawner instead of Events and Movement Core, I was able to spawn in 7287 events before I dropped below 30 FPS. So for some reason Events and Movement Core reduces the maximum amount of events I can spawn by like 15x.
So for some reason Events and Movement Core reduces the maximum amount of events I can spawn by like 15x.
That is a drastic difference. I know most people aren't going to actually hit such a wild number like that normally, but I can't help but wonder why the performance is hit so hard.
VisuStella Events and Movement Core actually does drastically reduce the maximum number of events that you can have on the map at the same time, but it still shouldn't be quite as bad as you're describing.

I did a test back in July, where I used Events and Movement Core to continuously spawn events (they did have a sprite... but no animation, movement route, or event commands) until my FPS dropped below 30. Using Events and Movement Core, I was able to spawn 473 events before my FPS dropped below 30. Since I was using a sprite, and you're not, I would expect that your results should be better than mine... plus my PC is kinda old. I would have been using slightly older versions of MZ and the plugin back then though, so I guess it's possible that something has changed since then.

Events and Movement Core definitely does cause problems though, because when I tried the same test using Galv's Event Spawner instead of Events and Movement Core, I was able to spawn in 7287 events before I dropped below 30 FPS. So for some reason Events and Movement Core reduces the maximum amount of events I can spawn by like 15x.
I did happen to find that after finding the cause and searching. I am running a good chunk of plugins, however disabling Events & Movement immediately has me back at my max FPS with the same events. Unfortunately one of the plugins I get great use out of, CommonEventMenu, needs Events & Movements to work. Otherwise I could probably have found an alternative.

I'm not really sure what to do at the moment, as I need to tackle this now - before it bites me later. So I'll have to search around and think about it. Unlucky me!
I'm on 1.4.3 with no issues on movement core. But I don't think they have updated their plugins for 1.6 yet as they said they were waiting for it to be stable first as of last report. Probably will happen with the January update when they post it.

However on FPS if you use the plugin for encounter effects, the default pathfinding on there is a HUGE resource hog. Changing that to rush in the default settings and change the time well down from the default of 600 frames will help the FPS a ton I found.
I'm on 1.4.3 with no issues on movement core. But I don't think they have updated their plugins for 1.6 yet as they said they were waiting for it to be stable first as of last report. Probably will happen with the January update when they post it.

However on FPS if you use the plugin for encounter effects, the default pathfinding on there is a HUGE resource hog. Changing that to rush in the default settings and change the time well down from the default of 600 frames will help the FPS a ton I found.
It would be great if their January update indeed does help then.

As for the encounter stuff, the above test was purely the existence of the events. They're completely empty, doing nothing. I have zero pathfinding in my project currently, minus standard player mouse clicks.
Right. But you will want to keep that in mind IF you add that plugin.

Also I find large maps do struggle on integrated graphics. I got my PC running on the integrated graphics just so I can see how it is doing.
That is a drastic difference. I know most people aren't going to actually hit such a wild number like that normally, but I can't help but wonder why the performance is hit so hard.
If I were to venture a guess, I'd probably blame it on the sheer number of features that are packed into the plugin. Since it has features that mess with collision, activation regions, activation radius, click triggers, etc... it is likely that every frame, it has to iterate through every event on the map and run code to check all that stuff (even if you aren't necessarily using those features). So the more events you have, the more the performance overhead of those features will snowball. Though it's also possible that they just have a bug or a really suboptimal algorithm somewhere in the plugin.

The fact that the plugin is obfuscated doesn't help either, since the obfuscation method that VS uses basically deoptimizes the entire plugin. I actually did test a deobfuscated version of the plugin as well, and was able to spawn 1051 events, compared to the 473 from the obfuscated version. So the obfuscation is cutting the performance of the plugin in half. But the problem still runs deeper than that, since I can still get 7x more events using Galv's Event Spawner.

While most users won't ever use such a large number of events on one map, there are some situations where it might actually be plausible. For example, if your game makes heavy use of something like VisuStella Furniture System (which unfortunately requires Events and Movement Core to be installed).
If I were to venture a guess, I'd probably blame it on the sheer number of features that are packed into the plugin. Since it has features that mess with collision, activation regions, activation radius, click triggers, etc... it is likely that every frame, it has to iterate through every event on the map and run code to check all that stuff (even if you aren't necessarily using those features). So the more events you have, the more the performance overhead of those features will snowball. Though it's also possible that they just have a bug or a really suboptimal algorithm somewhere in the plugin.

The fact that the plugin is obfuscated doesn't help either, since the obfuscation method that VS uses basically deoptimizes the entire plugin. I actually did test a deobfuscated version of the plugin as well, and was able to spawn 1051 events, compared to the 473 from the obfuscated version. So the obfuscation is cutting the performance of the plugin in half. But the problem still runs deeper than that, since I can still get 7x more events using Galv's Event Spawner.

While most users won't ever use such a large number of events on one map, there are some situations where it might actually be plausible. For example, if your game makes heavy use of something like VisuStella Furniture System (which unfortunately requires Events and Movement Core to be installed).
Yeah, that would've been my guess too. I've noted this to folks before, but there is a lot of functionality in the VS suite. That's not exactly a bad thing or anything, but it can lead to having too many features when you only need one or two. It can also, as you put forth, lead to performance problems because the plugin is consistently running code you may not even need to be ran all the time.

I have nothing to add regarding the obfuscation. You pretty much nailed it, and that poor horse has died long ago.
The best I could find from further testing was that, I think, 3 of VS' plugins are interacting with each other.
Events & Movements Core, Message Core and AttachedPictures.
On a fresh project (also enabled Options Core for easy FPS counter), having all 3 on significantly decreased FPS on a map with many blank events. Excluding Options Core, disabling 1 of any of the 3 plugins would have my FPS back at max.

I increased the number of events after, and although FPS improved still - only AttachedPictures had me back at max FPS when disabled. So I'm guessing that one has the worst impact. Bad enough that I would consider my issue solved for now by simply keeping AttachedPictures disabled, as that alone in my personal project was enough to get my FPS back into a reasonable range for now. I can make do without that particular plugin. I did bug report this to VS in case they can do something with that info.

I thought I should share it here, in case anyone could benefit from the info.

Original thread: https://forums.rpgmakerweb.com/threads/event-performance-optimisation.154101/