YEngine

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Improved script syntax)
 
(50 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{Quicklinks|YEngine}}
 +
 
=Summary=
 
=Summary=
  
This is a fully functional alternative to XEngine for LSL/OSSL scripts, featuring
+
This is a fully functional alternative to [[XEngine]] for LSL/OSSL scripts, featuring
  
 
* Preemptive Multitasking
 
* Preemptive Multitasking
 
* Improved script syntax
 
* Improved script syntax
 +
* Expressions evaluation order closer to original LSL specification
 
* Memory heap and stack use control per script
 
* Memory heap and stack use control per script
 
* Optional new language extensions
 
* Optional new language extensions
 +
 +
YEngine does direct translation from script language to .net IL code, this makes it compile faster than XEngine.
 +
XEngine translates script language to C#, and then uses .net compiler to generate IL, this is naturally slower.
 +
While XEngine could compile scripts in other languages like C#, YEngine only supports LSL.
 +
Due to security issues, those other languages could not be actually used, except on very special and restricted cases.
 +
 +
Once a script code is loaded on XEngine, the memory used by it can not be recovered whne the script is deleted, unless a .net feature called AppDomains are used<br>
 +
But AppDomains are very heavy, use a lot more memory and worse, have a huge negative impact on scripts performance<br>
 +
On calls crossing domains ( ie the script and main framework) all parameters and return values are serialized and deserialized by sender and receiver domains.<br>
 +
 +
Yengine loads scripts code in a diferent way, most their memory is recovered on delete without the need for those AppDomains.
  
 
= Preemptive Multitasking =
 
= Preemptive Multitasking =
 
YEngine executes script events using preemptive multitasking.<br>
 
YEngine executes script events using preemptive multitasking.<br>
This means that, at certain control points or when told, a script may release execution, waiting in a queue until it is its turn to execute again.<br>
+
This means that, at certain control points or when told, a script may release execution, being placed on a queue waiting for its turn to execute again.<br>
 
The released execution thread goes on processing other scripts.<br>
 
The released execution thread goes on processing other scripts.<br>
A script event can run for about 60ms until releasing execution. Then on continuations it can run for about 30ms. (This times may change)<br>
+
 
The script can also be placed in a sleep state until a sleep time elapses.<br>
+
When a new event started execution, it will be allowed to run for about 60ms (subject to change) until releasing execution.
This, for example, solves one of XEngine worse problems: llSleep() and other internal script sleeps. On YEngine, this just release execution and wait in a queue, until the sleep time expires. On XEngine a "expensive" execution thread was placed in Sleep mode, so not available to do anything.
+
When it is is turn to execute again it will be allowed to run for another 30ms(subject to change). This will be repeated until all the event code is executed<br>
 +
Engine will give more priority to short fast events.
 +
 
 +
The script can also be placed in a sleep state until a sleep time lapses.<br>
 +
This, for example, solves one of XEngine worse problems: llSleep() and other internal script sleeps. On YEngine, this just releases execution and waits in a queue, until the sleep time expires. On XEngine an "expensive" execution thread was placed in Sleep mode, so not available to do anything.
  
 
= Improved script syntax =
 
= Improved script syntax =
Line 29: Line 47:
 
are now errors
 
are now errors
  
complex statements execution order may be different from XEngine. One should always use (..) to enforce it the wanted order! (and in any language)
+
= Expressions evaluation order =
 +
 
 +
Complex statements execution order is closer to LSL specification than XEngine execution order.
 +
 
 +
for example, with i = 1;
 +
((i == 2) && (i++ == 1))
 +
 
 +
will evaluate to true as by LSL spec, while on XEngine it will evaluate to false, because it will do (i == 2) first
 +
 
 +
Even if not useful in this case, <b>always use parentheses (...) to enforce the order you need (and do this in any language)!</b>
  
 
= New language extensions =
 
= New language extensions =
 
<div style="background-color:#FFA500; padding:10px; padding-bottom:5px; border: 1px #FF544F solid">
 
<div style="background-color:#FFA500; padding:10px; padding-bottom:5px; border: 1px #FF544F solid">
 
This information is relative to version Yeti 0.9.2.0 Dev, with older version use just only normal LSL/OSSL
 
This information is relative to version Yeti 0.9.2.0 Dev, with older version use just only normal LSL/OSSL
</div>
+
</div><br>
  
If the first or second line of a script is (first line can still be script engine and language selection)
+
<div style="background-color:#FFA0A0; padding:10px; padding-bottom:5px; border: 1px #FF544F solid">
 +
Scripts using these features will only work on a compatible YEngine version. They will not compile or run on XEngine or older versions of YEngine.
 +
</div><br>
 +
 
 +
If the second line of a script is (currently first line needs to be present, empty or with script engine selection)
 
  yoptions;
 
  yoptions;
  
Yengine specific language extensions are activated
+
The following Yengine specific language extensions are activated
  
 
* [[YENGswitch | switch]]
 
* [[YENGswitch | switch]]
Line 45: Line 76:
 
* [[YENGcontinue | continue]]
 
* [[YENGcontinue | continue]]
 
* [[YENGtry | try catch and finally]]
 
* [[YENGtry | try catch and finally]]
 +
* [[YENGconstant | constant]]
 +
* [[YENGShortcircuit | short circuit AND and OR]]
  
 
+
Scripts using these features will not compile or run on XEngine.
Scripts using this features will not compile or run on XEngine.
+
  
 
= Memory heap and stack use control =
 
= Memory heap and stack use control =
Yengine keeps control of the memory a script uses.<br>
+
YEngine keeps control of the memory a script uses.<br>
 
There are two types of memory:<br>
 
There are two types of memory:<br>
 
* Stack holds function arguments and simple local variables.<br>
 
* Stack holds function arguments and simple local variables.<br>
 
* Heap holds global variables and complex variables like lists or strings, even if they are local to a method/event.<br>
 
* Heap holds global variables and complex variables like lists or strings, even if they are local to a method/event.<br>
  
the maximum values a script can use can be configured in OpenSim.Ini section [YEngine]
+
The maximum memory a script can use can be configured in the OpenSim.ini section [YEngine]
  
 
  ; maximum stack a script can use in KB
 
  ; maximum stack a script can use in KB
Line 63: Line 95:
 
  ;ScriptHeapSize = 1024
 
  ;ScriptHeapSize = 1024
  
 
+
You may need to increase these values
you may need to increase this values
+
  
 
= Activation =
 
= Activation =
Opensimulator default configuration selects XEngine. To change to YEngine you need to change OpenSim.ini:<br>
+
OpenSimulator default configuration selects XEngine. To change to YEngine you need to change OpenSim.ini:<br>
 
[Startup] section:
 
[Startup] section:
  
  DefaultScriptEngine = "YEngine"
+
  DefaultScriptEngine= "YEngine"
  
[Yengine] section:
+
[YEngine] section:
  
 
  Enable = true
 
  Enable = true
  
[Xengine] section:
+
[XEngine] section:
  
 
  Enable = false
 
  Enable = false
  
  
Note: in theory, opensimulator could run several engines at same time, but we should not do that with X and Y engines.
+
Note: in theory, OpenSimulator could run several engines at the same time, but we should not do that with X and Y engines.
  
 
= Configuration =
 
= Configuration =
 
Please see file OpenSimDefaults.ini, section [YEngine] for details.<br>
 
Please see file OpenSimDefaults.ini, section [YEngine] for details.<br>
Like on all case, if you need to change something, copy respective lines to similar location on file OpenSim.ini, and change there
+
As in all case, if you need to change something, copy respective lines to similar location on file OpenSim.ini, and change there
  
 
= Origins =
 
= Origins =
YEngine is a modified derivative of XMREngine<br>
+
YEngine is a modified derivative of XMREngine.<br>
XMREngine was developed by teams of DreamNation and Avination grids. With early work from Meta<br>
+
XMREngine was developed by teams of DreamNation and Avination grids, based on early work by Meta7.<br>
It is still in use by DreamNation<br>
+
It is still in use by DreamNation.<br>
  
 
http://wiki.dreamnation.net/index.php/XMREngine_Script_Engine
 
http://wiki.dreamnation.net/index.php/XMREngine_Script_Engine
  
A lot of information about XMREngine no longer applies to YEngine
+
A lot of information about XMREngine no longer applies to YEngine. Some features may still work, but may be removed or changed.
 +
 
 +
[[Category:Scripts]]

Latest revision as of 12:53, 21 August 2022

Contents

[edit] Summary

This is a fully functional alternative to XEngine for LSL/OSSL scripts, featuring

  • Preemptive Multitasking
  • Improved script syntax
  • Expressions evaluation order closer to original LSL specification
  • Memory heap and stack use control per script
  • Optional new language extensions

YEngine does direct translation from script language to .net IL code, this makes it compile faster than XEngine. XEngine translates script language to C#, and then uses .net compiler to generate IL, this is naturally slower. While XEngine could compile scripts in other languages like C#, YEngine only supports LSL. Due to security issues, those other languages could not be actually used, except on very special and restricted cases.

Once a script code is loaded on XEngine, the memory used by it can not be recovered whne the script is deleted, unless a .net feature called AppDomains are used
But AppDomains are very heavy, use a lot more memory and worse, have a huge negative impact on scripts performance
On calls crossing domains ( ie the script and main framework) all parameters and return values are serialized and deserialized by sender and receiver domains.

Yengine loads scripts code in a diferent way, most their memory is recovered on delete without the need for those AppDomains.

[edit] Preemptive Multitasking

YEngine executes script events using preemptive multitasking.
This means that, at certain control points or when told, a script may release execution, being placed on a queue waiting for its turn to execute again.
The released execution thread goes on processing other scripts.

When a new event started execution, it will be allowed to run for about 60ms (subject to change) until releasing execution. When it is is turn to execute again it will be allowed to run for another 30ms(subject to change). This will be repeated until all the event code is executed
Engine will give more priority to short fast events.

The script can also be placed in a sleep state until a sleep time lapses.
This, for example, solves one of XEngine worse problems: llSleep() and other internal script sleeps. On YEngine, this just releases execution and waits in a queue, until the sleep time expires. On XEngine an "expensive" execution thread was placed in Sleep mode, so not available to do anything.

[edit] Improved script syntax

YEngine follows more closely the LSL script syntax and execution order. statements like

if(oneKey)
   ...

should now work.

llSomething; // missing()
break; // but see new extensions

are now errors

[edit] Expressions evaluation order

Complex statements execution order is closer to LSL specification than XEngine execution order.

for example, with i = 1;

((i == 2) && (i++ == 1))

will evaluate to true as by LSL spec, while on XEngine it will evaluate to false, because it will do (i == 2) first

Even if not useful in this case, always use parentheses (...) to enforce the order you need (and do this in any language)!

[edit] New language extensions

This information is relative to version Yeti 0.9.2.0 Dev, with older version use just only normal LSL/OSSL


Scripts using these features will only work on a compatible YEngine version. They will not compile or run on XEngine or older versions of YEngine.


If the second line of a script is (currently first line needs to be present, empty or with script engine selection)

yoptions;

The following Yengine specific language extensions are activated

Scripts using these features will not compile or run on XEngine.

[edit] Memory heap and stack use control

YEngine keeps control of the memory a script uses.
There are two types of memory:

  • Stack holds function arguments and simple local variables.
  • Heap holds global variables and complex variables like lists or strings, even if they are local to a method/event.

The maximum memory a script can use can be configured in the OpenSim.ini section [YEngine]

; maximum stack a script can use in KB
;ScriptStackSize = 2048
   
; maximum heap memory a script can use in KB
;ScriptHeapSize = 1024

You may need to increase these values

[edit] Activation

OpenSimulator default configuration selects XEngine. To change to YEngine you need to change OpenSim.ini:
[Startup] section:

DefaultScriptEngine= "YEngine"

[YEngine] section:

Enable = true

[XEngine] section:

Enable = false


Note: in theory, OpenSimulator could run several engines at the same time, but we should not do that with X and Y engines.

[edit] Configuration

Please see file OpenSimDefaults.ini, section [YEngine] for details.
As in all case, if you need to change something, copy respective lines to similar location on file OpenSim.ini, and change there

[edit] Origins

YEngine is a modified derivative of XMREngine.
XMREngine was developed by teams of DreamNation and Avination grids, based on early work by Meta7.
It is still in use by DreamNation.

http://wiki.dreamnation.net/index.php/XMREngine_Script_Engine

A lot of information about XMREngine no longer applies to YEngine. Some features may still work, but may be removed or changed.

Personal tools
General
About This Wiki