Jump to content
MarkCode82

Why do people still use execVM? Instead of spawn?

Recommended Posts

In a nutshell execVM does this. -> compile PreProcessFileLineNumbers spawn { "myFunc".sqf"}

spawn is done first with
func = compile PreProcessFileLineNumbers "myFunc.sqf";

[] spawn func;

Share this post


Link to post
Share on other sites

execVM from what I  remember is mainly for more one and done type scripts. you don't need to be calling it over and over and recompiling each time (it clogs up the scheduler queue when you overuse it), and if its only used once then theres practically no point in assigning it a spot in memory if it won't be used again. (it also returns a script handle which can be used to monitor script status)

  • Like 2

Share this post


Link to post
Share on other sites

Yeah but pre-compiling accelerates the functions execution. E.g I&A has an AO script thats run every cycle. Because it's being repeatedly used I set it to a cfgFunctions Pre-compiled function. Hell I compile ALL my code. Not a single bit is run via execVM.

  • Like 1

Share this post


Link to post
Share on other sites

I tell u a secret but try to be not shocked to much. There are guys anywhere out there which, hell, execVM ALL their code. Not a single bit is precompiled.

But who cares about?

Share this post


Link to post
Share on other sites

Yeah but pre-compiling accelerates the functions execution. 

 

Functions, yes. You don't use execVM for functions because by definition they're executed multiple times. execVM, as austin mentioned, is for one-time only scripts that are thrown away afterwards. It's good practice to write functions if you're using the code multiple times, but most of the time in Arma you will not be using code multiple times (like setting a task - you can obviously write a function for it, yes, but you might as well do a script if you're only setting it once. This approach obviously depends on how you go about it). The performance gain is often minimal and you need to do a lot of looping and scheduling to bring the whole ship down burning and crashing and all that if you want to burn Armas actual FPS to the ground. 

 

I'm not saying code optimisation is shit and shouldn't be looked after, but writing functional code that works even if it uses scheduled environment is #1 priority every time. 

 

If you're interested in some stats when it comes to code optimisation: https://community.bistudio.com/wiki/Code_Optimisation 

  • Like 1

Share this post


Link to post
Share on other sites

Most of the "lower level" tutorials out there use execVM because throwing people that have zero coding knowledge into function file structure, compilation, and optimization is just too complicated when a new coder just wants to create something as simple as a dynamic marker on an objective after it's completed. And since most people start on the lower levels, they don't learn about the use of call/spawn until later in their coding careers, so they use execVM instead, where they don't need to think about suspension or locality (as much anyways) or other topics that aren't so easily understood.

  • Like 7

Share this post


Link to post
Share on other sites

And then you realize BI uses multiple execVM every time client joins session, on both client and server.

 

Laziness, lack of knowledge or hubris, reasons I can think of for people to spam execVM when pre-compile is the better option.

 

Sometimes execVM is the correct choice, when script is executing only once, no need to leave memory footprint by compiling into a variable.

 

Certainly when I started arma coding I overused execVM, learned bad habits from Xeno :)

 

session initialization:

if (isserver) then {
    [] execvm "initServer.sqf";
    "initServer.sqf" call bis_fnc_logFormat;
};
 
//--- Run mission scripts
if !(isDedicated) then {
    [player,didJIP] execvm "initPlayerLocal.sqf";
    [[[player,didJIP],"initPlayerServer.sqf"],"bis_fnc_execvm",false,false] call bis_fnc_mp;
    "initPlayerLocal.sqf" call bis_fnc_logFormat;
    "initPlayerServer.sqf" call bis_fnc_logFormat;
};


I still use execVM sometimes, but only for purpose of triggering peoples OCD

  • Like 3

Share this post


Link to post
Share on other sites

Most of the "lower level" tutorials out there use execVM because throwing people that have zero coding knowledge into function file structure, compilation, and optimization is just too complicated.

 

^ This or out of sheer lazyness.

 

Otherwise I'd always recommend using the functions library in combination with either spawn or call.

  • Like 1

Share this post


Link to post
Share on other sites

Thats what I use, I have begun re-writing I&A for scability beyond what it currently can do.

Such as ambient AO caches from enemies players can take advantage of etc.

Share this post


Link to post
Share on other sites

Hello, I am not a script writer. I have been running arma 2 and 3 servers, I have set up over 20 of them. Went from not knowing anything 4 years ago to keeping my servers running.

With that said: I have used execVM alot.

My question is, lets say I build a AI City  i.e. buildings, roads, and trees.  Lets say I call it ai_city.sqf  When I call for it when the server starts, How should it be called?

I have used both, but in this instance its not clear for me.

Share this post


Link to post
Share on other sites

Hello, I am not a script writer. I have been running arma 2 and 3 servers, I have set up over 20 of them. Went from not knowing anything 4 years ago to keeping my servers running.

With that said: I have used execVM alot.

My question is, lets say I build a AI City  i.e. buildings, roads, and trees.  Lets say I call it ai_city.sqf  When I call for it when the server starts, How should it be called?

I have used both, but in this instance its not clear for me.

https://community.bistudio.com/wiki/execVM explained here

  • Like 1

Share this post


Link to post
Share on other sites

For Arma 2 and 3, what would be the best language to learn?  i.e. C++?  I read what killzone_kid posted for me and understand the base of the execVM, but want to learn more.

Share this post


Link to post
Share on other sites

For Arma 2 and 3, what would be the best language to learn?  i.e. C++?  I read what killzone_kid posted for me and understand the base of the execVM, but want to learn more.

The language used is sqf, so learn that, but if your're looking for more of a real world application C++/Java would be a good start as Arma does mirror concepts in sqf.

However this is off topic from this thread, if you want to continue this discussion I recommend you PM someone or start your own discussion thread on the subject.

  • Like 1

Share this post


Link to post
Share on other sites

Closest language to SQF is probably Java and C smashed together. ArmA 3 uses a Virtual Machine interpreter much like Java. Except I don't think arma 3 does Byte code conversion.

And I'll stick with compiling all my code purely for the reason of anti-hack protection builtin into it.

  • Like 2

Share this post


Link to post
Share on other sites

Hello, I am not a script writer. I have been running arma 2 and 3 servers, I have set up over 20 of them. Went from not knowing anything 4 years ago to keeping my servers running.

With that said: I have used execVM alot.

My question is, lets say I build a AI City  i.e. buildings, roads, and trees.  Lets say I call it ai_city.sqf  When I call for it when the server starts, How should it be called?

I have used both, but in this instance its not clear for me.

 

 

There is actually multiple methods for this discussed at length here.

http://www.ofpec.com/tutorials/index.php?action=show&mode=new&id=287

Your AI-city could be run via call compileFinal PreprocessFileLineNumbers "ai_city.sqf";

This gives you all the capability of compiling it along with a more "secure hack protected" code.

but it throws away the result of the function. saving memory.

  • Like 1

Share this post


Link to post
Share on other sites

This thread made me rewrite all of my current mission scripts. :/

For testing, though, I'll have to say it's less convenient to precompile everything. Before, I could simply edit a certain script and see the difference live in gameplay. With precompiling it, of course this doesn't work anymore.

Share this post


Link to post
Share on other sites

The thread title makes it sound like execVM is some ancient outdated command.

 

I usually run everything from my own functions library, even functions that only run 2-3 times per mission.

Can't think of a function in my library that doesn't get used at least twice each mission, besides pre/post init functions, which requires them to be set up as functions anyway.

 

execVM is still getting used when editing a function/idea on the fly or to release one function as a stand alone script for others to use.

 

I doubt there's actually any noticeable performance impact on memory or fps using execVM vs call/spawn.

Any one got any numbers regarding this?

 

Cheers

Share this post


Link to post
Share on other sites

The thread title makes it sound like execVM is some ancient outdated command.

 

I usually run everything from my own functions library, even functions that only run 2-3 times per mission.

Can't think of a function in my library that doesn't get used at least twice each mission, besides pre/post init functions, which requires them to be set up as functions anyway.

 

execVM is still getting used when editing a function/idea on the fly or to release one function as a stand alone script for others to use.

 

I doubt there's actually any noticeable performance impact on memory or fps using execVM vs call/spawn.

Any one got any numbers regarding this?

 

Cheers

 

while i dont care too much about performance optimizing in SQF, it certainly is noticeable drag on performance if compiling lots of code. 

 

execvm = spawn compile loadfile

 

better to compile the code and store in memory than to load CPU with recurring compilation, and to do it at start of session prior to clients joining, when no one will notice the stuttering.

Share this post


Link to post
Share on other sites

The thread title makes it sound like execVM is some ancient outdated command.

 

I usually run everything from my own functions library, even functions that only run 2-3 times per mission.

Can't think of a function in my library that doesn't get used at least twice each mission, besides pre/post init functions, which requires them to be set up as functions anyway.

 

execVM is still getting used when editing a function/idea on the fly or to release one function as a stand alone script for others to use.

 

I doubt there's actually any noticeable performance impact on memory or fps using execVM vs call/spawn.

Any one got any numbers regarding this?

 

Cheers

there is a drag on performance (albeit if its just one tiny little script it probably won't mean much in the grand scheme), as execVM recompiles off the disk each time its run (especially if its a hard drive, ssd not as big of a performance hit because of higher read/write speed), wasting time that could be better spent doing another task.

Share this post


Link to post
Share on other sites
I have read what has be posted here, but lets look at this. I have a folder that I keep all my AI Citys in (not all my creations)

 

custom_Chernarus11\AI_CITYS\Aerial_Patrol

custom_Chernarus11\AI_CITYS\AI Prision

custom_Chernarus11\AI_CITYS\ai_outpost

and more (there are a total of 14 "Not running at the same time")

 

In my server_functions.sqf I have this at the bottom.

 

//*******AI CITYS GO BELOW HERE*******

[] execVM "custom_Chernarus11\AI_CITYS\Aerial_Patrol\Aerial_Patrol.sqf";

 

[] execVM "custom_Chernarus11\AI_CITYS\Banko_Mat\Banko_Mat_init.sqf";

 

[]execVM "custom_Chernarus11\AI_CITYS\black_forest\black_forest_outpost_init.sqf";//near black forest

 

//[]execVM "custom_Chernarus11\AI_CITYS\pobeda_ai_city\pobeda_ai_city_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\Orlovets\Orlovets_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\ai_outpost\ai_outpost_init.sqf";

 

//[] execVM "custom_Chernarus11\AI_CITYS\pavlovo\pavlovo_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\sectorC\sectorC_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\sectorfng\sectorfng_init.sqf";

 

[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\Compton AI City\compton_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\AI Prison\AI_Prison_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\Qdoba\qdoba_init.sqf";

 

//[]execVM "custom_Chernarus11\AI_CITYS\DevilCastle\devilcastle_init.sqf";

 

Lets look in the skalisty_island folder. I have a file called skalisty_island_init.sqf

in that file I have the following:

 

[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_castle.sqf";//castle on Skalisty Island

 

[] execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_lottery.sqf"; //AI Bandit Island

 

[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_road.sqf";//roads on Skalisty Island

 

[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_wall.sqf";//wall around Skalisty Island

 

[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\spawn_box_skalisty_island.sqf";//random box on Skalisty Island

 

[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\SpecialWeaponsBox.sqf";//weapons to take out tanks and helis

 

My question is, how should it all be called? I have been using this for over 3.5 years. Seems to work fine. The thing is I am trying to get better, that why Im here. :a:

Share this post


Link to post
Share on other sites

testing with 

hint "testing"; 

inside a code block for spawn and call, and test.sqf for execVM

 

execVM has longest execution time, where as spawn at the lowest. (all were under .4 ms, spawn was closer to .3)

 

SPAWN: 0.0035ms

CALL: 0.0368ms

EXECVM: 0.394945ms (only 2532 cycles, spawn and call were able to achieve 10,000/10,000)

 

obviously loading it once into RAM then calling from there after the first run resulted in better performance, not that anyone was expecting anything different.

  • Like 1

Share this post


Link to post
Share on other sites

Just wanted to compare execVM vs cfgFunctions, unfortunately the performance button in the debug gui breaks if I use execVM. Guess it takes too long.

 

 

 

 

I have read what has be posted here, but lets look at this. I have a folder that I keep all my AI Citys in (not all my creations)
 
custom_Chernarus11\AI_CITYS\Aerial_Patrol
custom_Chernarus11\AI_CITYS\AI Prision
custom_Chernarus11\AI_CITYS\ai_outpost
and more (there are a total of 14 "Not running at the same time")
 
In my server_functions.sqf I have this at the bottom.
 
//*******AI CITYS GO BELOW HERE*******
[] execVM "custom_Chernarus11\AI_CITYS\Aerial_Patrol\Aerial_Patrol.sqf";
 
[] execVM "custom_Chernarus11\AI_CITYS\Banko_Mat\Banko_Mat_init.sqf";
 
[]execVM "custom_Chernarus11\AI_CITYS\black_forest\black_forest_outpost_init.sqf";//near black forest
 
//[]execVM "custom_Chernarus11\AI_CITYS\pobeda_ai_city\pobeda_ai_city_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\Orlovets\Orlovets_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\ai_outpost\ai_outpost_init.sqf";
 
//[] execVM "custom_Chernarus11\AI_CITYS\pavlovo\pavlovo_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\sectorC\sectorC_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\sectorfng\sectorfng_init.sqf";
 
[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\Compton AI City\compton_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\AI Prison\AI_Prison_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\Qdoba\qdoba_init.sqf";
 
//[]execVM "custom_Chernarus11\AI_CITYS\DevilCastle\devilcastle_init.sqf";
 
Lets look in the skalisty_island folder. I have a file called skalisty_island_init.sqf
in that file I have the following:
 
[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_castle.sqf";//castle on Skalisty Island
 
[] execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_lottery.sqf"; //AI Bandit Island
 
[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_road.sqf";//roads on Skalisty Island
 
[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\skalisty_island_wall.sqf";//wall around Skalisty Island
 
[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\spawn_box_skalisty_island.sqf";//random box on Skalisty Island
 
[]execVM "custom_Chernarus11\AI_CITYS\skalisty_island\SpecialWeaponsBox.sqf";//weapons to take out tanks and helis
 
My question is, how should it all be called? I have been using this for over 3.5 years. Seems to work fine. The thing is I am trying to get better, that why Im here. :a:

 

 

Go ahead and read this and you'll be one step closer to getting better ;) https://community.bistudio.com/wiki/Functions_Library_(Arma_3)

  • Like 1

Share this post


Link to post
Share on other sites

Just wanted to compare execVM vs cfgFunctions, unfortunately the performance button in the debug gui breaks if I use execVM. Guess it takes too long.

I was able to do it just fine and dandy. (look at my above post)

  • Like 1

Share this post


Link to post
Share on other sites
On 3.8.2016 at 1:52 AM, MarkCode82 said:

 

 

There is actually multiple methods for this discussed at length here.

http://www.ofpec.com/tutorials/index.php?action=show&mode=new&id=287

Your AI-city could be run via call compileFinal PreprocessFileLineNumbers "ai_city.sqf";

This gives you all the capability of compiling it along with a more "secure hack protected" code.

but it throws away the result of the function. saving memory.

 

Is this where all the compileFinal nonsesnse comes from that I see more and more often recently?
compileFinal only set's the final flag in the compiled code. Which only does something if you store it in a variable.
If you don't store it at all it does nothing at all.
So "secure hack protected" code is completely wrong.

 

On 3.8.2016 at 6:16 PM, austin_medic said:

testing with 


hint "testing"; 

inside a code block for spawn and call, and test.sqf for execVM

 

execVM has longest execution time, where as spawn at the lowest. (all were under .4 ms, spawn was closer to .3)

 

SPAWN: 0.0035ms

CALL: 0.0368ms

EXECVM: 0.394945ms (only 2532 cycles, spawn and call were able to achieve 10,000/10,000)

 

obviously loading it once into RAM then calling from there after the first run resulted in better performance, not that anyone was expecting anything different.

 

Your benchmarking is faulty.

With spawn the code is already compiled and it doesn't even execute the code. Which is why it's fastest.

With call your code is already compiled and is actually executed which is why it's "slower" than spawn although it isn't at all.
With execVM your code IS NOT compiled already. Meaning execVM first compiles your code and then does a spawn.
And compiling stuff is slow.

Correct benchmark would be

private _script = spawn compile preprocessFileLineNumbers "test.sqf"; waitUntil {scriptDone _script};
call compile preprocessFileLineNumbers "test.sqf";

private _script = [] execVM "test.sqf"; waitUntil {scriptDone _script};

But remember that you sometimes don't want to wait till your script is done. You just wanna have it run in the background. And if you only run it once then execVM is the best method.

Scripts that you often execute should be pre-compiled using CfgFunctions and then called/spawned depending on whether you want to wait for it to be done.

 

 

On 2.8.2016 at 3:52 AM, MarkCode82 said:

In a nutshell execVM does this. -> compile PreProcessFileLineNumbers spawn { "myFunc".sqf"}

spawn is done first with
func = compile PreProcessFileLineNumbers "myFunc.sqf";

[] spawn func;

 

You meant execVM does "spawn compile PreprocessFileLineNumbers "myFunc.sqf" right?

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×