YEngine
From OpenSimulator
(→Summary) |
|||
(22 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | {{Quicklinks|YEngine}} |
− | + | ||
=Summary= | =Summary= | ||
Line 8: | Line 7: | ||
* Preemptive Multitasking | * Preemptive Multitasking | ||
* Improved script syntax | * Improved script syntax | ||
− | * Expressions evaluation order closer to | + | * 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 | ||
Line 48: | Line 47: | ||
are now errors | are now errors | ||
− | Complex statements execution order | + | = 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 = | ||
Line 62: | Line 70: | ||
yoptions; | yoptions; | ||
− | Yengine specific language extensions are activated | + | The following Yengine specific language extensions are activated |
* [[YENGswitch | switch]] | * [[YENGswitch | switch]] | ||
Line 70: | Line 78: | ||
* [[YENGconstant | constant]] | * [[YENGconstant | constant]] | ||
* [[YENGShortcircuit | short circuit AND and OR]] | * [[YENGShortcircuit | short circuit AND and OR]] | ||
− | |||
Scripts using these features will not compile or run on XEngine. | Scripts using these features will not compile or run on XEngine. |
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.