Jump to content
Sign in to follow this  
Pussycat Catnap

Is mono always better than lsl for scripts I make?

Recommended Posts

Ancient news that mono came out to replace LSL, if I remember right (hope I don't have this backwards)?

I make a tiny script:

default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

    touch_start(integer total_number)
    {
        llSay(0, "Touched.");
    }
}

And save it as LSL. It allocates 16kbs. We know it is actualy using less right?

I save it as Mono. It allocates 64kbs. We know it is actualy using less right?

 

I wear this thing as an attachment. All those script meters and such now say I'm using up 64kbs. We know this isn't actually true right?

So... I presume Mono is supposed to always be better because:

  1. It is faster right?
  2. It doesn't re-load on sim crossings? (Is this not even true for LSL. I remember talk of this back in 2009)
  3. It may have allocated 64kb, and LSL allocated 16kbs, but the mono one is actually using less than the LSL?
  4. Other reasons I don't know?

- Are my reasons correct or wrong?

 

Is there ever a case for using LSL?

 

Share this post


Link to post
Share on other sites

And save it as LSL. It allocates 16kbs. We know it is actualy using less right?

No. LSO scripts always really use the full 16K whether they need it or not.

 

I save it as Mono. It allocates 64kbs. We know it is actualy using less right?

For your example, yeah. You can play with llSetMemoryLimit to force the script to show a lower limit, useful if you know you won't need more and want to look nice on the various tracking boards and so on.

Share this post


Link to post
Share on other sites

Thank you for that note. I played around with a memory test to see what you were referring to:

 

integer memoryLimit = 12288; // Cap the script to this memory usage.testMemory(){    llScriptProfiler(PROFILE_SCRIPT_MEMORY);    llOwnerSay("Limited Memory " + (string)llGetMemoryLimit() +              "\nUsed Memory " + (string)llGetUsedMemory() +              "\nFree Memory " + (string)llGetFreeMemory());    llScriptProfiler(PROFILE_NONE);    llOwnerSay("AnimationController script used at most " + (string)llGetSPMaxMemory() + " bytes of memory during Test.");}default{    state_entry()    {        llSetMemoryLimit(memoryLimit);...

And sure enough my results for mono and then lsl:

 

Limited Memory 12288Used Memory 11598Free Memory 690[10:57] Neko Tail - Pussycat Custom: AnimationController script used at most 11598 bytes of memory during Test.[10:57] Neko Tail - Pussycat Custom: Limited Memory 16384Used Memory 16384Free Memory 13663[10:57] Neko Tail - Pussycat Custom: AnimationController script used at most 16384 bytes of memory during Test.

I also noticed that I cannot cheat. I tried setting this script to a limit of 1228 and to 10288 and both times it reported the limit as 65536, and a nearby script monitor I was using listed me at 62kbs instead of '11' as it was when I set the limit properly.

- That's important to know. It means this feature is not an 'exploit', but a way to self-police and self-monitor.

 

I'm making a little thing where I can control the animations in a bento tail using a chat channel rather than HUD - and want it to be lightweight, and to report back as lightweight.

 

But the question extends beyond that as I have a lot of scripts I've been writing and making sure I'm doing them in the best way I can figure out is important.

So thank you for responding. :)

 

Share this post


Link to post
Share on other sites

Regarding Memory:

An LSL script always uses 16k.

A Mono script only uses what it needs. For your example that will be less than 1k. 

llSetMemoryLimit is not needed and has no effect - don't use it. It does not change the amount of memory that is used. It only sets a limit for the memory a script can use at max. 

If you copy that script 100 times this 100 scripts will use 1k (NOT 100k - since its the same code it is only stored once)

Your other points:

- yes, it is faster (by my observations)
- It can use more memory (max 64k) if thats needed.
- It can use even more memory for a short time without triggering an overflow. If - for example - you exceed the max memory by calling a function with a long parameter list - that is tolerated if you are under the limit after the call.
- I didnt do many sim crossing things for a long while so cant tell you any differences here.
- Nobody but the mono script itself know how much memory is used. A check by an other script will always show 64k.

Of course that means the so called script meters show completely wrong numbers if they focus on memory usage. I suggest to delete that crap if it only focuses on memory. Script execution time is more interesting but difficult to determine since mono scripts have a peak at the moment they rez. The meter-script needs to repeat the check a few times.

 

Share this post


Link to post
Share on other sites


Nova Convair wrote:

 

llSetMemoryLimit is not needed and has no effect - don't use it. It does not change the amount of memory that is used. It only sets a limit for the memory a script can use at max. 

That is poor and incorrect advice, why that is so has already been discussed upthread. Social matters, even if it is beyond your comprehension.

Share this post


Link to post
Share on other sites

Was curious so reran some tests on llGetObjectDetails results and can confirm - if llSetMemoryLimit() is used

somewhere in script (else full 64k returned), for 4 MONO scripts in a prim

Without memory limiter I get :

Name = MONO object
Scripts running = 4
Total Scripts = 4
Memory used = 262144

With limit :

Name = MONO object (4096 limit)
Scripts running = 4
Total Scripts = 4
Memory used = 16384

Nice to check though.

Share this post


Link to post
Share on other sites

As I explained, llGetObjectDetails does not give you the used memory, only the max possible memory. If you don't understand the difference you should try to change that. :)

 

Share this post


Link to post
Share on other sites

Y'all know you're in agreement here, right?

That's in contrast to how Mono memory usage used to engender debate every time a thread like this came up. For ages, it was a regular thing that somebody would say llSetMemoryLimit() reduced the amount of memory actually allocated to the script. It's an advance in SL scripting sophistication that we all know better now.

As Cerise points ouit, there still are times when llSetMemoryLimit has utility, but that's way less common than we expected back when it was new, sim memory was a scarce resource, and we anticipated memory quotas per-avatar and per-land-area. We even worried how products would express their script memory usage, expecting it to be as essential as permissions and prim count.

To the main point: Yeah, I can imagine a non-Mono compile to still have a small advantage in sim crossing, but not if that required more scripts than with Mono compilation. Even then, if the Mono script were enough smaller than 16K it might possibly win. This is all guesswork, though, and probably hopeless to test reliably given the instruments we have.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...