So I've been working on Marine Arena for the last couple of months adding new features and abilities, but one of the most notable changes that I can't seem to get to the bottom of is there is a large amount of lag that wasn't present in earlier versions of the game. I'm not really sure where to begin. Granted it IS a massing game so some lag is to be expected, but we have players who could run at a decent FPS now slowing to a crawl under the same circumstances.
Some things that might be helpful to know:
- Unit spawns are done entirely through the data editor except for marines using a "every X seconds, do this" trigger
- Triggers run each time a unit spawns to issue orders to make another unit (like Nexus Wars)
- There is a leaderboard that tracks kill counts every time a unit is slain
- Issue seemed to start occurring at a time when we added an upgrade that decreased build times for units, however the lag persists even before this upgrade is purchased by anyone
- Most new features and abilities were added strictly through the data editor, so not a huge amount of triggers are actually in the map (maybe 100 or so if I were to guess).
Can anyone provide tips based on this? Or maybe you have ideas based on what you have seen in the game? Thanks!
How often do periodic effects really need to occur? Are there any loops in triggers and is everything terminating correctly without any loose ends. You could use the Train ability to automatically use an Issue Order effect to make it start training a new unit by the way. Do any of your actors use timers? How many units/doodads are on the screen at once? Sure certain abilities do not leave persistents undestroyed? Are all custom actors destroyed (especially impacts) after use and not persisting in an invisible state?
Odds are it is triggers or timers that are causing it. Consider asking an expert if he can look over your triggers. I advise SoulCarveRR on this site or my brother DrSuperGood on THW.
I wasn't aware there was an issue order effect, that's incredibly helpful to know and could reduce some of the trigger strain. Thanks Dr, I'll look into your other suggestions as well.
Actually we've been incorporating a good number of new behaviors and one of the newest features we're doing adds like 3 behaviors to every unit. I'm already starting to dread the bad news now :(
a lot of persistents and missiles are also causing lag. check the fatty unit at income wars, it searches for up to 5 targets and creates 5 persitents launching 4 missiles each. had to reduce it because this simple thing caused noticable lag as soon as there where 3 or more of them
a lot of persistents and missiles are also causing lag. check the fatty unit at income wars, it searches for up to 5 targets and creates 5 persitents launching 4 missiles each. had to reduce it because this simple thing caused noticable lag as soon as there where 3 or more of them
Is this sort of lag something that permeates through the entire game after the unit starts firing missiles or just while its on the field?
From my personal tests, lags are usually caused by
massive amounts of visual effects (obviously), especially particle effects
particle effects with modified scale, opacity or time scale, even very few of them (however other people do not seem to be ableconfirm this. Might be an issue with my pc or graphics settings)
costly trigger actions executed for triggers, which trigger very often (periodic triggers with low periods, triggers registering for any damage, mouse movement, keyboard keys, any UI buttons...). If used carefully, those events can be fine, though. Its not the event itself causing lag; in most cases, it is the action.
behaviors with a huge stack count (>255)
I cannot confirm, that huge amounts of (low stacked) behaviors, effects or many actor timers cause noticeable lag. As long as there is no visual representation for those actions, everything seems to run smoothly. The data editor seems to be quite efficient for that matter.
Other than that, in many cases it is indeed an error; actors, which do not get destroyed or get created for the wrong events, or use wrong actor events in general; triggers or effect chains calling way more effects/actions than intended. This seems to happen surprisingly often.
I don't claim my tests to be the undeniable truth, though. I tested reasonable as well as absolutely ridiculous amounts of data objects for lag in singleplayer as well as battlenet, but always alone; that might cause a huge difference. However even for the ridiculous amounts most data stuff performed quite well, as long as there are no ridiculous amounts of visuals or behavior stacks involved.
this is more a "the moment the unit fires" lag. it was crazy visible in the graph in the debug window. you said you use a lot of data.
did you take a look there whats happening on your map? if anything crazy is visible.
If you state it like that, its not correct. Unit group or player group picks are quite efficient, actually. The problem is obviously, that, if you pick all units on the map, you probably have a huge amount of units, which potentially leads to a huge amount of functions being called.
However, this still does not mean, that it would affect the performance in a negative way. It depends on the actions you actually execute.
oh didn't test it, sounds good. and the game breaks the trigger if it takes to long to perform it.
in the debug window are some other good informations, like how long a trigger took on average
oh didn't test it, sounds good. and the game breaks the trigger if it takes to long to perform it.
in the debug window are some other good informations, like how long a trigger took on average
I've never used the debug window, is it a command during a test game? How's it work?
DrSuperEvil, I swapped all my spawning triggers for train effects like you recommended and the results are immediately noticeable. Thanks so much for pointing that out :)
I've never used the debug window, is it a command during a test game? How's it work?
It can be activated in the test document settings withing the editor. However, it is not really useful for checking performance, because just enabling it will drop the performance by a great deal, just because of all the additional debug information, which is being processed.
Bumping this thread because the problem persists. Marine Arena remains pretty laggy (I know it's a massing map, but earlier versions did not have this much constant lag). Since opening the thread I have done a few things to try and alleviate the problem.
- Changed all triggers related to mercenary spawning to abilities in the data editor instead
- Changed marine spawning to happen entirely in the data editor as well
- Removed 40+ triggers and loops relating to spawning and special abilities that affected spawning
Since doing this though the difference seems negligible. I'm starting to think it might be either a trigger based on a very broad event (but couldn't all triggers be considered fairly broad? Player presses any key? A unit is attacked? etc.) or a specific unit with an ability that is causing issues. My next step is removing all non-essential triggers and units from the map and publishing a test to see what happens. I guess I was just sharing my thoughts in this thread and looking for any more feedback anyone might have.
Do you many periodic events? Events seem to be the primary culprit of lag. I did some trials some time back and found that a trigger that runs an event once every 1/16th of a second lags, but a trigger action with a loop that iterates at the same rate doesn't.
I think the any key event might cause it too, along with mouse movement, anything that spams events will cause lag.
Sometimes, I have the feeling, that I am talking to a brick wall... :D
Like mentioned earlier in this thread, periodic event or periodic loop does only make a significant difference, if you test in singleplayer and especially with an open debug window.
It is, at least to my current knowledge, not 100% confirmed, which of both methods is actually more performant ingame, but if you plan on testing a lot with the debug window, you should probably use the loop, because the event will render the map unplayable in no time.
Commonly, it is stated, that a loop might have a slight edge, performance-wise, but uses an active thread at all times, while the event does not count towards the thread limit constantly, but needs a little (as in usually not even noticeable) more resources. However, as far as I am aware, this is purely theorycrafting and not confirmed in any way.
So I've been working on Marine Arena for the last couple of months adding new features and abilities, but one of the most notable changes that I can't seem to get to the bottom of is there is a large amount of lag that wasn't present in earlier versions of the game. I'm not really sure where to begin. Granted it IS a massing game so some lag is to be expected, but we have players who could run at a decent FPS now slowing to a crawl under the same circumstances.
Some things that might be helpful to know:
- Unit spawns are done entirely through the data editor except for marines using a "every X seconds, do this" trigger
- Triggers run each time a unit spawns to issue orders to make another unit (like Nexus Wars)
- There is a leaderboard that tracks kill counts every time a unit is slain
- Issue seemed to start occurring at a time when we added an upgrade that decreased build times for units, however the lag persists even before this upgrade is purchased by anyone
- Most new features and abilities were added strictly through the data editor, so not a huge amount of triggers are actually in the map (maybe 100 or so if I were to guess).
Can anyone provide tips based on this? Or maybe you have ideas based on what you have seen in the game? Thanks!
How often do periodic effects really need to occur? Are there any loops in triggers and is everything terminating correctly without any loose ends. You could use the Train ability to automatically use an Issue Order effect to make it start training a new unit by the way. Do any of your actors use timers? How many units/doodads are on the screen at once? Sure certain abilities do not leave persistents undestroyed? Are all custom actors destroyed (especially impacts) after use and not persisting in an invisible state?
Odds are it is triggers or timers that are causing it. Consider asking an expert if he can look over your triggers. I advise SoulCarveRR on this site or my brother DrSuperGood on THW.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
I wasn't aware there was an issue order effect, that's incredibly helpful to know and could reduce some of the trigger strain. Thanks Dr, I'll look into your other suggestions as well.
In addition to what DrSuperEvil said, how many behaviors are there on the map at the same time? I know this caused a ton of lag in my map.
@TheAlmaity: Go
Actually we've been incorporating a good number of new behaviors and one of the newest features we're doing adds like 3 behaviors to every unit. I'm already starting to dread the bad news now :(
a lot of persistents and missiles are also causing lag. check the fatty unit at income wars, it searches for up to 5 targets and creates 5 persitents launching 4 missiles each. had to reduce it because this simple thing caused noticable lag as soon as there where 3 or more of them
Is this sort of lag something that permeates through the entire game after the unit starts firing missiles or just while its on the field?
From my personal tests, lags are usually caused by
I cannot confirm, that huge amounts of (low stacked) behaviors, effects or many actor timers cause noticeable lag. As long as there is no visual representation for those actions, everything seems to run smoothly. The data editor seems to be quite efficient for that matter.
Other than that, in many cases it is indeed an error; actors, which do not get destroyed or get created for the wrong events, or use wrong actor events in general; triggers or effect chains calling way more effects/actions than intended. This seems to happen surprisingly often.
I don't claim my tests to be the undeniable truth, though. I tested reasonable as well as absolutely ridiculous amounts of data objects for lag in singleplayer as well as battlenet, but always alone; that might cause a huge difference. However even for the ridiculous amounts most data stuff performed quite well, as long as there are no ridiculous amounts of visuals or behavior stacks involved.
@Lucavious: Go
this is more a "the moment the unit fires" lag. it was crazy visible in the graph in the debug window. you said you use a lot of data.
did you take a look there whats happening on your map? if anything crazy is visible.
costly triggers: pick every xyz
If you state it like that, its not correct. Unit group or player group picks are quite efficient, actually. The problem is obviously, that, if you pick all units on the map, you probably have a huge amount of units, which potentially leads to a huge amount of functions being called.
However, this still does not mean, that it would affect the performance in a negative way. It depends on the actions you actually execute.
oh didn't test it, sounds good. and the game breaks the trigger if it takes to long to perform it.
in the debug window are some other good informations, like how long a trigger took on average
Triggered sound effects cause massive amounts of lag for some insane reason. If you have a lot of them, remove them.
I've never used the debug window, is it a command during a test game? How's it work?
DrSuperEvil, I swapped all my spawning triggers for train effects like you recommended and the results are immediately noticeable. Thanks so much for pointing that out :)
It can be activated in the test document settings withing the editor. However, it is not really useful for checking performance, because just enabling it will drop the performance by a great deal, just because of all the additional debug information, which is being processed.
Very useful for spotting trigger errors, though.
Bumping this thread because the problem persists. Marine Arena remains pretty laggy (I know it's a massing map, but earlier versions did not have this much constant lag). Since opening the thread I have done a few things to try and alleviate the problem.
- Changed all triggers related to mercenary spawning to abilities in the data editor instead
- Changed marine spawning to happen entirely in the data editor as well
- Removed 40+ triggers and loops relating to spawning and special abilities that affected spawning
Since doing this though the difference seems negligible. I'm starting to think it might be either a trigger based on a very broad event (but couldn't all triggers be considered fairly broad? Player presses any key? A unit is attacked? etc.) or a specific unit with an ability that is causing issues. My next step is removing all non-essential triggers and units from the map and publishing a test to see what happens. I guess I was just sharing my thoughts in this thread and looking for any more feedback anyone might have.
Good discussion. Any other ideas on how to reduce lag?
@Lucavious: Go
Do you many periodic events? Events seem to be the primary culprit of lag. I did some trials some time back and found that a trigger that runs an event once every 1/16th of a second lags, but a trigger action with a loop that iterates at the same rate doesn't.
I think the any key event might cause it too, along with mouse movement, anything that spams events will cause lag.
Sometimes, I have the feeling, that I am talking to a brick wall... :D
Like mentioned earlier in this thread, periodic event or periodic loop does only make a significant difference, if you test in singleplayer and especially with an open debug window.
It is, at least to my current knowledge, not 100% confirmed, which of both methods is actually more performant ingame, but if you plan on testing a lot with the debug window, you should probably use the loop, because the event will render the map unplayable in no time.
Commonly, it is stated, that a loop might have a slight edge, performance-wise, but uses an active thread at all times, while the event does not count towards the thread limit constantly, but needs a little (as in usually not even noticeable) more resources. However, as far as I am aware, this is purely theorycrafting and not confirmed in any way.