This is a simple trigger. When dialog item is pressed, selected units for player are ordered to attack move towards enemies. This causes a massive FPS drop. So thought maybe it was because they were all being ordered at once, so I added a wait instead of doing them all at once. Now what happens is my FPS is fine until every unit is ordered. Then, after every unit is ordered, my FPS drops to 5-10 (from above 100) for a few seconds, and then returns to normal.
I'm stumped. If it was due to that many units moving at once causing lag, you'd think it'd happen as the units were being ordered, and last until they stopped being ordered or stop moving. But no. It happens AFTER every unit is ordered, and it only lasts a short amount of time. Is this some kind of built-in garbage collection from blizzard causing the issue? Any help is appreciated.
SeekNFightEventsDialog-AnyDialogItemisusedbyPlayerAnyPlayerwitheventtypeClickedDialog-AnyDialogItemisusedbyPlayerAnyPlayerwitheventtypeHotkeyPressedLocalVariablesUnit=NoUnit<Unit>UnitGroup=(Emptyunitgroup)<UnitGroup>Player=0<Integer>LessLag?=(Emptyunitgroup)<UnitGroup[4]>
Conditions
Actions
Unit Group - Remove all units from Unit Group
Variable - Set Player = (Triggering player)
General - If (Conditions) then do (Actions) else do (Actions)
If
(Used dialog item) == SeeknFight
Then
Dialog - Hide SeeknFight Button for (Player group(Player))
Dialog - Hide SeeknFight for (Player group(Player))
General - Wait 0.1 Game Time seconds
Dialog - Show SeeknFight Button for (Player group(Player))
Dialog - Show SeeknFight for (Player group(Player))
Unit Group - Add all units in (Selected units for player Player) to Unit Group
Unit Group - For each unit Unit in Unit Group do (Actions)
Actions
Unit - Order Unit to ( Attack targeting ((Position of (Random Living unit from (Units in (Entire map) having alliance Enemy with player Player matching Excluded: Neutral, Worker, Missile, Dead, Hidden, Hallucination, Invulnerable, with at most Any Amount))) offset by (Random real between 4.0 and 13.0) towards (Random real between 0.0 and 360.0) degrees)) (Replace Existing Orders)
General - Wait 0.0001 Game Time seconds
General - Wait 0.05 Game Time seconds
Else
try a wait time of 0.125, mimimum wait time is 0.0625.
make unit group of enemies and use a random unit from this unitgroup instead of creating the unitgroup for each ordered unit again.
how many units are you ordering in average?
It is only hypothetical, but I think that your loop is to heavy and make the rest late in his execution while your loop is executed.
So you have lag, but as your loop has ended, the rest can free his delay, as there is no more the heavy loop executing.
You use 3 random functions, and in a loop like this one, executed almost instantly even if you delay by 0.0625, it can be heavy if as Funky suggests it, there is many units. Maybe you should check what happens if you replace these 4 random functions by fixed values.
No idea how Blizzard implemented these random functions, one (or more than one) of these may be heavy to execute.
Random real is not costly. 1k executions use 0.431ms on my computer which is pretty much nothing. The trigger debugger is good at showing how the native functions perform.
Btw, if there is no enemy unit left on the map, the trigger will create errors.
I have recreated your trigger in a test map and I do not experience any big FPS drops. I am applying this to 500 units. The pathing in my test map is quite simple.
After selecting 500 Marines, I have 161 fps. After the trigger finishes, I have 71 fps and the game does not drop below that level.
Skunk, do you experience the problem in my test map, too?
I reduced the Marine's movement speed, so there is a lot of time before the units start fighting as there my FPS dropped down to 37 FPS with normal speed, I assume due to alerts and new pathfinding to targets and around neighbor units firing. I've tested with the 64 bit client.
This is a simple trigger. When dialog item is pressed, selected units for player are ordered to attack move towards enemies. This causes a massive FPS drop. So thought maybe it was because they were all being ordered at once, so I added a wait instead of doing them all at once. Now what happens is my FPS is fine until every unit is ordered. Then, after every unit is ordered, my FPS drops to 5-10 (from above 100) for a few seconds, and then returns to normal.
I'm stumped. If it was due to that many units moving at once causing lag, you'd think it'd happen as the units were being ordered, and last until they stopped being ordered or stop moving. But no. It happens AFTER every unit is ordered, and it only lasts a short amount of time. Is this some kind of built-in garbage collection from blizzard causing the issue? Any help is appreciated.
try a wait time of 0.125, mimimum wait time is 0.0625.
make unit group of enemies and use a random unit from this unitgroup instead of creating the unitgroup for each ordered unit again.
how many units are you ordering in average?
It is only hypothetical, but I think that your loop is to heavy and make the rest late in his execution while your loop is executed. So you have lag, but as your loop has ended, the rest can free his delay, as there is no more the heavy loop executing.
You use 3 random functions, and in a loop like this one, executed almost instantly even if you delay by 0.0625, it can be heavy if as Funky suggests it, there is many units. Maybe you should check what happens if you replace these 4 random functions by fixed values.
No idea how Blizzard implemented these random functions, one (or more than one) of these may be heavy to execute.
Random real is not costly. 1k executions use 0.431ms on my computer which is pretty much nothing. The trigger debugger is good at showing how the native functions perform.
Btw, if there is no enemy unit left on the map, the trigger will create errors.
I have recreated your trigger in a test map and I do not experience any big FPS drops. I am applying this to 500 units. The pathing in my test map is quite simple.
After selecting 500 Marines, I have 161 fps. After the trigger finishes, I have 71 fps and the game does not drop below that level.
Skunk, do you experience the problem in my test map, too?
I reduced the Marine's movement speed, so there is a lot of time before the units start fighting as there my FPS dropped down to 37 FPS with normal speed, I assume due to alerts and new pathfinding to targets and around neighbor units firing. I've tested with the 64 bit client.
Hmm yes 0.431 becomes nothing compared to the waiting time.
try Pick Each Unit In Unit Group and Order Picked Unit