Let's talk about trigger lag

Sud

"[If life=Dota] I'd have quit long ago" -- Acehart
Reaction score
64
I have 401 triggers currently that I'm dealing with. I've done a pretty good job thus far optimizing these, but it seems I'm going to need to crunch them around further as trigger lag is starting to set in.

And so it comes to be that I want to talk about trigger lag. In particular, the particulars. I'm using a lot of different triggers to do different things, but I've got some suspicons about them. For example, I use a lot of unit is attacked triggers. I have good conditions that should prevent the trigger from being run often, but I have to wonder if the mere existance of this type of trigger is contributing to the lag, or is it really dormant until it's called upon?

Another suspicion might be triggers dealing with unit creation and giving orders to units. A lot of creating and ordering takes place. Relatively speaking, does anyone have any sort of concrete ideas on how much overhead unit creation and orders should create?
 

Jazradel

Helping people do more by doing less.
Reaction score
102
Well I'm not really sure what you can do but I have these words of advice.
Use Lightning Orb as a base for on attack abilitys.
Delete 1 shot triggers after their run.
 

Sud

"[If life=Dota] I'd have quit long ago" -- Acehart
Reaction score
64
If you need to delete 1 shot triggers after running them, then it would stand to reason their mere existance in the map causes lag?

Reason I'm asking is that in my situation, almost all the hero abilities are triggered in some way or another (and a lot of item abilities). However, only a possible 10 heroes can be picked (out of 15 total currently). That's 5 heroes worth of triggers I could possibly eliminate.

But does this matter? Those triggers will not be run (and some initialization triggers will only be run once). Do the existance of triggers cause problems?
 

Grundy

Ultra Cool Member
Reaction score
35
every time a unit is attacked it will check the conditions that you have in every one of your "unit is attacked" triggers
 

Sud

"[If life=Dota] I'd have quit long ago" -- Acehart
Reaction score
64
Correct, the question is, is it negligable or something I actually really want to work to eliminate if I can?

Quick question - I saw that WEU has a destroy trigger function, does normal warcraft have this (or will just turning the trigger off suffice?)
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,491
There's some talk every now and then.
And, well, the "conclusions" are far from it.

About the only suggestion that would make some sense would be:
" Keep the number of events down. Use "IF" if you needed. "
It's debatable, but, the number of events..., like I said, seems to make some sense.

As for the "destroy trigger function"...
Oh, dear.
If you ask me, that would be an old wives' tale, or, maybe, an urban legend.
Otherwise, do some search here to read all of the weirdest stuff :)
(WEU only BTW)

Once upon a time, I was also worried about "a unit is attacked".
Then I found out that there's a rather famous map from around here,
that makes good use of it.
No lag.


Casting Fire Bolt on a unit, and it dies.
What events does that cause?

begins casting
unit is attacked
starts the effect
unit takes damage
unit dies
finishes casting

Any more?

Now, it's really all event based.
Had a look at the JASS version of some trigger?
Says "register event".
Should mean that, as the game is playing, there's, for example, some unit under attack.
So, the event manager is told "unit is attacked".
Any trigger that registered that event is then added to the trigger queue.
It will NOT have a look through each and every trigger
to see if maybe, or not, that trigger might be interested in that event.
Once that event done, the triggers will start to run.
Next event, next list, next...

All of this is quite interesting and, yes, I would like to have a long talk
with some Blizzard internal about it.

Until then...


Are you experiencing lag? Due to triggers?
 

Sud

"[If life=Dota] I'd have quit long ago" -- Acehart
Reaction score
64
Verily. Especially with some very intensive triggers. It has been growing though, so I think I'm just starting to experience the effects of critical mass or maybe even a clog in the queue.

For example, one of my Pyro's skills, firewall, never really used to generate any sort of lag, but as of recently, I've been starting to feel it in games, especially when I'm playing 4v4 or 5v5. I haven't done anything to modify or change that skill in a long time, it's just something that started creeping its way in.

Of course, I can't say there's no lag because my map regularly chews up and spits out people with crappy computers. If you're not running something at least over 2Ghz, you're going to get absolutely destroyed by low fps, so any optimizations that I can possibly do might work to make the game a little less restrictive.

What I'm going to try to do is maybe cut down on some of the overhead. I'm working right now to initially start all my hero skill related triggers set to off (as opposed to being on as before) and only turn them on when people pick the associated heroes. Worth a shot anyways. I'll report back if I can get any kind of performance increase.
 

Sud

"[If life=Dota] I'd have quit long ago" -- Acehart
Reaction score
64
Here's an update for anyone who was interested.

I achieved excellent results with the tactic I stated above in reducing the in-game lag in the map. Where the game used to have significant chop-out periods in 4v4s and even 3v3s, I was able to host a 5v5 last night on the new version with only one slightly choppy period all game (and that was basically because I summoned about 20 units into someone's AOE effect while their summon had summoned 6 subunits and it was just all over the place, but it only lasted for about 1 second).

So what I've concluded from this is that any active trigger, regardless of whether or not it's being evaluated past its conditions, will cause lag and will eventually create a critical mass if there are too many of them.

The fix to this is to turn off all triggers that are not being used. In particular, I turned off all my hero triggers, and only let them be turned on when a hero is picked. So in a 5v5, 6 hero's worth of triggers are left off.

It's good that this worked, now I have to do the same with my item triggers.
 

SD_Ryoko

Ultra Cool Member
Reaction score
86
The Lag List. In order of priority:
-Destroy any unit pick groups or player group picks using a custom script line. With abilities, these add up big time.
-Keep triggers that fire when 'a unit is attacked' or 'a unit dies' off if its not needed.
-Keep your code clean and efficent. Avoid loops. wherever you can. Excessive loops need workarounds.
-Avoid nested loops. Avoid nested loops that pick all units or players. There are workarounds for this also.
(especially when checking inventory slots. I seen loops three-deep)
-Keep spawn and movement triggers seperate. More efficient processing small conditions, than a gigantic list every time an event happens.
-Combine triggers that could be. Dont keep 15 if one trigger with 15 events will do it.

Inline your map! INLINE YOUR MAP
It has been proven, World Edit does a horrible deed. All strings are stored in a seperate file. Every time an ability tooltip, an item, or a text message needs a string, it has to look through this file of some 3000 strings to find it.

The inliner takes EVERY STRING out of that stupid file, and puts it in the correct one. Abilities, Items, Trigger code, Map Description, everything. Inlining should be done one step before protection & release.

JASS not GUI
On another note, when you use GUI to make triggers with a lot of if statements, and conditions, World editor creates a function for EVERY condition. If your trigger is DONE, you can convert it to JASS, and combine like 15 conditions into one clean, in-lined trigger. I do this a lot. This is so important. I think Vex's optomizer does this to an extent as well. Its the 'combine condition' option.

What are you doing!?
One of the biggest lag problems is doing something dumb like picking 12 players, and processing an array 80 deep for each player, with nested loops inside as well, picking units too.

File Sizes?
Imports bogging you down? Not models. Models are small. Take your 256x256 skins and convert em to 128x128. It makes about 1/4 of the file size, and odds are, you'll NEVER NOTICE. I use this a lot - especially on over done graphics like the aliens model. It never displays that detailed anyway.

Services Hee hee.

I can also look at maps from time to time, and clean them up. I've done it a few times for allstars (even though I was somewhat ignored.) And I'm pretty good at doing all the above mentioned.
 

Sud

"[If life=Dota] I'd have quit long ago" -- Acehart
Reaction score
64
Does the Vex optimizer include inlining? I'm using it currently.
 

SD_Ryoko

Ultra Cool Member
Reaction score
86
If you check 'Optomize String Usage'.

Even after protection, you can open/view the map in WINMPQ, and look at the WTS file. Should be 1k or less after a sucessfull pass.

However, the method of seeing files is also the method of cracking protected maps, so I will not say here. :D

Vexorians program had a problem with WAV and MP3 - It can't compress them and actually makes your map bigger. Which is a problem indeed. Not sure about the status of this yet, or if it is fixed.
 

PB_and_J

level 85 anti-spammer
Reaction score
41
I'm pretty sure that you can also do this. Once ur map inti. triggers are done you can destroy em because there never going to be used again.
corect me if im wrong
 

Shadowy Fear

I have returned
Reaction score
44
Ryoko, you mentioned not to use loops --- I thought my third person camera loop (based off the one in the free trigger code by Darg, but with a unit array that I set at the beginning of the map and occasionally at certain points throughout [random, based on player activity] that then does the trigger for player interger a and for unit interger a --- it works without a hitch on 1 player mode, but now I'm a bit confused --- I was certain one for each player at the same time would cause massive lag) would be more effecient and less laggy than creating a seperate third person camera trigger for every player.

Can you tell me what the problem is? Or do you mean loops like --- every .5 seconds, pick every unit in region owned by player random interger between 1 and 12 and do set hp to 10?

Forgive my ignorance.
 

Shadowy Fear

I have returned
Reaction score
44
Ok, good, I think my stuff should be simple enough that that doesn't happen :) Just sets the camera to a unit from a cool perspective that allows you to really view the terrain --- only trouble is when you click on a wall that's looming in front of your camera but behind your unit, and your hero goes off in a random direction -_-.
 

Sud

"[If life=Dota] I'd have quit long ago" -- Acehart
Reaction score
64
Apparently global weather effects cause havoc on people with crappy computers.

I can't verify, as I don't have a crappy computer heh.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • jonas jonas:
    Which company do you work for?
  • vypur85 vypur85:
    Haha yea they'd compare my country as well...
  • vypur85 vypur85:
    Hmm i don't receive any pm? Maybe I'm using my phone. Gonna check it out using my pc later.
  • vypur85 vypur85:
    I'm teaching A Levels in a school in Wuhan.
  • jonas jonas:
    You should see a "private conversations" tab in the chatbox, that's where I sent it to you
    +1
  • jonas jonas:
    Wow
  • jonas jonas:
    Is the school system in your country similar to Chinese school system? I could never imagine being a teacher in a Chinese school, what's expected of students and teachers is just so different from what I'd be looking for as a teacher
  • vypur85 vypur85:
    A Levels is based on the UK syllabus offered internationally. So the syllabus is similar throughout different countries, taught in english.
  • vypur85 vypur85:
    I can't speak or write or read much chinese... Too difficult....... Which also makes my life here in china a lil difficult.
  • jonas jonas:
    Oh, I see. I thought Chinese version of A-levels :D
  • jonas jonas:
    I've been using the translate app a lot on my phone. take a photo, translate. take another photo, translate again :D
  • jonas jonas:
    it also has voice translation, my colleagues sometimes use that
  • jonas jonas:
    You came during the 0 covid policy right? How'd you get through quarantine? Did you have some help with the apps and green codes?
  • tom_mai78101 tom_mai78101:
    If you have any Chinese you need help with, let me know.
  • vypur85 vypur85:
    @jonas Those were the things I did too. Translate app and VPN are always the most important things to have to survive. Lol.
  • vypur85 vypur85:
    Yea I came last year. I was quarantined for about 30 days. Fml. The first day of my quarantine was the eve of Chinese new year last year. Fml again... Lol.
  • vypur85 vypur85:
    @tom_mai78101 IIRC you're from Taiwan right.
  • The Helper The Helper:
    I thought China had cracked down on having any foreign teachers?
  • vypur85 vypur85:
    Yeah I've heard of the news before. My school is still actively hiring foreign teachers. Not sure how things work now.
  • The Helper The Helper:
    yeah it is hard to get reliable information about that kind of stuff
  • The Helper The Helper:
    but you are doing it so it is still doable
  • vypur85 vypur85:
    I think it doesn't affect existing foreign teachers. Then again, its still weird that my school is hiring.
  • The Helper The Helper:
    Happy Monday people hope everyone has a fantastic week!
  • Ghan Ghan:
    Happy Monday?! That's a contradiction.

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top