Operation limit

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Well, I had some trouble the last weeks with the operation limit.

Though I solved the problems, I was wondering if someone could give me proper information about the operation limit itself:


1) How many operations are (on average) required to reach the operation limit?

2) What possible ways are there to create a new threat and thus resetting the operation limit? I know that you can use zero-timers, but are there other more elegant ways?

3) Is there a way to detect wether you are close to the op limit?

That's all for now. Thanks in advance.
 

Azlier

Old World Ghost
Reaction score
461
2. The best way to avoid the op limit is by started a new thread via TriggerEvaluate or TriggerExecute.
 

weaaddar

New Member
Reaction score
6
1.The op limit is hard to calculate and not every action consumes equal amounts of it.
2. TriggerEvaluate, TriggerExecute or TriggerSleepAction. If you have a big loop you probably want to just add a sleep after some number of iterations.
3. No way to detect.
Actually here is my quick test suite.
JASS:
//! zinc
library test requires Table
{
    integer C0 = 0;
    integer C1 = 0;
    integer C2 = 0;
    integer C3 = 0;
    integer C4 = 0;
    integer C[];
    integer C10 = 0;
    integer C12 = 0;
    Table table;
    function test0()
    {
        while(true)
        {
            C0 +=1;
        }
    }
    
    function test1()
    {
        C1+=1;
        test1();
    }
    
    function test2(integer x)
    {
        C2+=1;
        test2(x);
    }
    function test3()->integer
    {
        C3+=1;
        return test3();
    }
    
    function test4(integer x)->integer
    {
        C4+=1;
        return test4(x);
    }
    
    function test5()
    {
        while(true)
        {
            C[0] +=1;
        }
    }
    
    function test6()
    {
        C[1]+=1;
        test6();
    }
    
    function test7(integer x)
    {
        C[2]+=1;
        test7(x);
    }
    function test8()->integer
    {
        C[3]+=1;
        return test8();
    }
    
    function test9(integer x)->integer
    {
        C[4]+=1;
        return test9(x);
    }
    
    function test10()
    {
        C10+=1;
        test10();
    }
    function test11()
    {
        table[0] +=1;
        test11();
    }
    
    function test12(integer x,integer y)
    {
        C12+=1;
        test12(x,y);
    }
    
    function onInit()
    {
        timer t = CreateTimer();
        timer t2 = CreateTimer();
        table = table.create();
        TimerStart(t,1,false,function()
        {
            BJDebugMsg("Globals");
            BJDebugMsg(I2S(C0));
            BJDebugMsg(I2S(C1));
            BJDebugMsg(I2S(C2));
            BJDebugMsg(I2S(C3));
            BJDebugMsg(I2S(C4));
            BJDebugMsg("arrays");
            BJDebugMsg(I2S(C[0]));
            BJDebugMsg(I2S(C[1]));
            BJDebugMsg(I2S(C[2]));
            BJDebugMsg(I2S(C[3]));
            BJDebugMsg(I2S(C[4]));
            BJDebugMsg("test10 "+I2S(C10));
            BJDebugMsg("test11 "+I2S(table[0]));
            BJDebugMsg("test12 "+I2S(C12));
        });
        test0.execute();
        test1.execute();
        test2.execute(0);
        test3.execute();
        test4.execute(0);
        test5.execute();
        test6.execute();
        test7.execute(0);
        test8.execute();
        test9.execute(0);
        TimerStart(t2,0,false,function test10);
        test11.execute();
        test12.execute(0,0);
    }
}

//! endzinc

Here are some quick thoughts:
1. Timer and trigger threads have the same number of ops.
2. Recursion gets more bang for your buck vs loop when you don't have parameters.

3. Array members consume much more op limit then non-array members. Hashtable consume even more.
4. Functions without parameters seem to preform the best, regardless of if they have a return.
5. The return statement seems to make no effect on op limit. This may because it never returns and thus never has to populate the stack.

Anyway the number is something like 33,333 global var reads in a loop or 45,000 global var reads in a recursive loop. Array reads are more get about 10,000 less on average. Inf recursion with a hashtable yielded a pathetic 15,000.

In theory if you want to be nuts you can just have a function that has 100,000 statements in it of all just a variable incrementing itself. It should crash and then one could figure out how many raw statements you can process in one function by using a similar approach. I think Cjass might be able to this.

The op limit can be kind of low, but as long as you don't try something crazy you should be safe.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Thanks for the detailed informations.
And yes, of course, the operation limit should - at least most of the time - not be a problem, but you can reach the op limit very fast with Map-Init functions, especially enumerations.

For example, in my rpg, I attach like 20-30 custom stats to all placed neutral hostile units on the map on map init, by just using global arrays with an indexing system. I was wondering why some mobs didn't have the custom stats, until I found out, that I exceeded op limit on map init.

I don't really understand why there is an operation limit to functions called on map init, as those functions are called during the map loading process anyways and thus can not create a "freeze", but well, that's blizzard logic.
 

Jesus4Lyf

Good Idea™
Reaction score
397
I don't really understand why there is an operation limit to functions called on map init, as those functions are called during the map loading process anyways and thus can not create a "freeze", but well, that's blizzard logic.
Try doing [LJASS]call TriggerExecute(GetTriggeringTrigger())[/LJASS] on map init and say that again. :thup:
You can freeze the map with object editor data even - an orb effect which fires itself (causes infinite loop on load). XD
 
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