Why does this lagg?

feelingparty

New Member
Reaction score
3
So something's wrong with my map because whenever there are more units on the screen there is a major drop-down in fps. There are some leaks that need clearing but that (i think) is not the case as the laggs are there from the beginning itself. For example I have this spell that shoots an arrow and a fiery dummy unit that i use for the effect. And everything works fine except that when I cast it my fps goes down from 63 to 18 until the arrow and the effect are dead then it goes up again. Any thoughts? Here is the movement trigger :
Trigger:
  • Move Proj
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Arrows and do (Actions)
        • Loop - Actions
          • Set Temp_Point = (Position of (Picked unit))
          • Set Temp_Point2 = (Temp_Point offset by (Load 3 of (Key (Picked unit)) from hasharrows) towards (Load 4 of (Key (Picked unit)) from hasharrows) degrees)
          • Set Temp_Group = (Units within 70.00 of Temp_Point)
          • Unit Group - Pick every unit in Temp_Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Not equal to FieldDummy
                  • (Unit-type of (Picked unit)) Not equal to FlamingArrow
                  • ((Picked unit) is dead) Equal to False
                • Then - Actions
                  • Set unit = (Picked unit)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 2 of (Key (Picked unit)) from hasharrows) Greater than or equal to 0.00
              • ((Picked unit) is alive) Equal to True
              • unit Equal to No unit
            • Then - Actions
              • Unit - Move (Picked unit) instantly to Temp_Point2
              • Hashtable - Save ((Load 2 of (Key (Picked unit)) from hasharrows) - (Load 3 of (Key (Picked unit)) from hasharrows)) as 2 of (Key (Picked unit)) in hasharrows
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to FieldDummy
                      • (Unit-type of (Picked unit)) Equal to FlamingArrow
                • Then - Actions
                  • Unit - Cause (Picked unit) to damage unit, dealing (Load 5 of (Key (Picked unit)) from hasharrows) damage of attack type Spells and damage type Normal
                  • Unit - Remove (Picked unit) from the game
                • Else - Actions
                  • Unit - Remove (Picked unit) from the game
          • Set unit = No unit
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Custom script: call RemoveLocation (udg_Temp_Point2)
          • Custom script: call DestroyGroup (udg_Temp_Group)


And here is the other trigger (even though i think the problem is in the upper)
Trigger:
  • Arrow Fire
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Shoot Flaming Arrow
          • (Ability being cast) Equal to Fletch Arrow
          • (Ability being cast) Equal to Shoot Flaming Arrow 2
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Shoot Flaming Arrow 2
        • Then - Actions
          • Unit - Create 1 FlamingArrow for (Triggering player) at ((Position of (Triggering unit)) offset by 100.00 towards (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees) facing (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees
          • Special Effect - Create a special effect attached to the overhead of (Last created unit) using Abilities\Spells\Other\BreathOfFire\BreathOfFireDamage.mdl
          • Hashtable - Save (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) as 4 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBspeed[(Player number of (Triggering player))] as 3 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBdistance[(Player number of (Triggering player))] as 2 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save (ATRIBattack[(Player number of (Triggering player))] x ATRIBattMultip[(Player number of (Triggering player))]) as 5 of (Key (Last created unit)) in hasharrows
          • Unit Group - Add (Last created unit) to Arrows
          • Unit - Create 1 FlamingArrowFX for (Triggering player) at ((Position of (Triggering unit)) offset by 100.00 towards (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees) facing (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees
          • Hashtable - Save (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) as 4 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBspeed[(Player number of (Triggering player))] as 3 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBdistance[(Player number of (Triggering player))] as 2 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save (ATRIBattack[(Player number of (Triggering player))] x ATRIBattMultip[(Player number of (Triggering player))]) as 5 of (Key (Last created unit)) in hasharrows
          • Unit Group - Add (Last created unit) to Arrows
        • Else - Actions
      • Sound - Play ArrowAttack1 <gen> at 100.00% volume, attached to (Triggering unit)
 

Ashlebede

New Member
Reaction score
43
You have to flush child hashtables, first of all.

Trigger:
  • Hashtable - Clear all child hashtables of child (Key unit) in H

Use this when you don't need it anymore. It will remove all the stored values for that unit in the Hashtable. This can cause leaks if you don't do it.

Making that action happen every .02 second can also alter performance. I usually use .04 or .03 delay.

Can't find anything else wrong, but from my experience, not clearing child Hashtables is verrry laggy. That should help at least a little.
 

feelingparty

New Member
Reaction score
3
thank you for your help. I changed the periodic to 0.04 (rescaled speed), added a clearing for the child hashtable. And the fps drop-down got halved. However if the ability is cast 2 or 3 times the fps goes to about 8 witch is insane considering my CPU is pretty good. Is there any way to completely remove it so it is possible to cast the spell multiple times?(The spell must be MUI after all.)
 

Ashlebede

New Member
Reaction score
43
There's always UserData which can be used instead of one of the Hashtable values and is quicker. However it can only store a single integer.

Trigger:
  • Actions
    • Unit - Set the custom value of (Triggering unit) to 10
    • Set int = (Custom value of (Triggering unit))

That could be a little less computer-hungry, but only for one value. Probably won't make a difference. Of course, you would have to convert the reals to integers...

You can also reduce lag from first run by calling this line at map init in a custom script:

JASS:
call Preload("My Special Effect's path")

Having the path to your special effect between the double-quotes, doubling all the backslashes. For instance, "Blah\Blahblah\Blah.mdl" would become "Blah\\Blahblah\\Blah.mdl".

This will pre-load the model file for your special effect, making some lag at map startup, but reducing the spikes caused by using abilities for the first time. (it would often make some 2-second spikes on Lagginator if I didn't preload)

Really can't find any leaks, though. I'm rather bad at analyzing others' code, too. :p
 

feelingparty

New Member
Reaction score
3
So I tried reworking everything. And I think the problem doesn't come from the hashtables nor from the models as i didn't use any of them (I used Custom Values when possible and preloaded all dummy models). I think that my Group-in-Group (for each unit in X pick each unit in Y and do actions) method doesn't work though. Any ideas how to bypass this?
 

Ashlebede

New Member
Reaction score
43
Trigger:
  • Set Temp_Group = Units within 70.00 of (Position of(Picked Unit)) matching {Condition}


Condition should use "Matching Unit" to refer to the unit for which you want to verify the condition. It then won't overlap with the units of the first loop... in theory...

Then, to check if there is a unit in the group, you have to verify like this :

Trigger:
  • (Number of units in Temp_Group) Equal to 0


That should do it, um... maybe....
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top