YEngine

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Memory heap and stack use control)
(link to the French translation)
(47 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{MainPageQuicklinks}}
 +
 +
 
=Summary=
 
=Summary=
  
This is a fully functional alternative to XEngine for LSL/OSSL scripts
+
This is a fully functional alternative to [[XEngine]] for LSL/OSSL scripts, featuring
  
 
* Preemptive Multitasking
 
* Preemptive Multitasking
 
* Improved script syntax
 
* Improved script syntax
* Memory heap and stack use control
+
* Memory heap and stack use control per script
* 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>
A script event can run for about 60ms before placed in queue, then on continuations it can run for about 30ms. (This times may change)<br>
+
The released execution thread goes on processing other scripts.<br>
The script can also be placed in a sleep state until a sleep time elapses.<br>
+
 
This, for example, solves one of XEngine worse problems: llSleep(). llSleep just places the script on a wait queue, until the sleep time expires, using no other execution resources
+
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<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 =
YEngine follows more closely LSL script syntax and execution order.
+
YEngine follows more closely the LSL script syntax and execution order.
 
statements like  
 
statements like  
 
  if(oneKey)
 
  if(oneKey)
Line 26: Line 45:
 
  break; // but see new extensions
 
  break; // but see new extensions
  
are now a 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)
+
Complex statements execution order may be different from XEngine. One should always use parentheses (...) to enforce the order wanted (and in any language)!
  
 
= 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 only normal LSL
+
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;
  
Line 44: Line 67:
 
* [[YENGcontinue | continue]]
 
* [[YENGcontinue | continue]]
 
* [[YENGtry | try catch and finally]]
 
* [[YENGtry | try catch and finally]]
 +
* [[YENGconstant | constant]]
 +
* [[YENGShortcircuit | short circuit AND and OR]]
  
  
Scripts using this features will not compile or run on XEngine.
+
Scripts using these 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 87:
 
  ;ScriptHeapSize = 1024
 
  ;ScriptHeapSize = 1024
  
 
+
You may need to increase these values
you may need to increase this values
+
  
 
= Activation =
 
= Activation =
Opensimulation 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 =
 +
Please see file OpenSimDefaults.ini, section [YEngine] for details.<br>
 +
As in all case, if you need to change something, copy respective lines to similar location on file OpenSim.ini, and change there
 +
 
 +
= Origins =
 +
YEngine is a modified derivative of XMREngine.<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>
 +
 
 +
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.
 +
 
 +
[[Category:Scripts]]

Revision as of 13:13, 2 December 2020


Contents

Summary

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

  • Preemptive Multitasking
  • Improved script syntax
  • 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.

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.

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

Complex statements execution order may be different from XEngine. One should always use parentheses (...) to enforce the order wanted (and in any language)!

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;

Yengine specific language extensions are activated


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

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

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.

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

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