Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetLinkPrimitiveParams() ??

Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
04-20-2009 13:23
From: Lear Cale
I stand corrected.

Regardless of the details, my original point still stands: content creators will have a big incentive to be efficient with memory, and that's a good thing for SL in general.


I agree with you, I like the change, and if it really does help cut the lag down caused by scripts, I'm all for it. I just wish they would take a serious look at some of their functions and make them memory friendly. I believe that lists are passed by reference, which is good, but I'd like to know for sure. Things like that, and as I mentioned before a simple boolean type would be nice as well, why use a full unsigned integer for a simple 0 or 1. Hopefully, this change will trigger better functions for us as well.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
04-20-2009 14:07
Lists are passed by value to user-coded functions. They've already defined the language as pass-by-value, and to change that would be likely to break content. While I woud personally have preferred pass-by-reference for all data types, I would strenuously argue against changing it at this point.

I believe they're also pass-by-value to built-in functions in old LSL bytecode.

In Mono, I don't know whether built-in functions are pass-by-reference. I sure do hope they are. Since they can be easily written to guarantee not changing the passed in values, this would save memory. Frankly, they could also be written pass-by-value, but using static memory allocated per-function, disallowing context changes inside LSL functions while the static memory is in use, and we'd get the same benefit. The bottom line is we don't want built-in functions using any more of the parcel's memory pool than absolutely necessary.

Fortunately, in Mono, appending an item to a list using "+=" does NOT cause the list to be duplicated (well, I'm kinda sorta pretty darn sure ... where's Strife when you need him?)
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
04-20-2009 14:19
From: Lear Cale
I believe they're also pass-by-value to built-in functions in old LSL bytecode.


I just ran a simple test, and it looks like built-in functions are passed by reference.

CODE

list gList = [];

BuildList()
{
integer index;
for(index = 0; index < 1000; index++)
{
gList += index;
}
}


default
{
state_entry()
{
BuildList();
llOwnerSay((string) llGetFreeMemory() + " Bytes.");
gList = llListSort(gList, 1, TRUE);
llOwnerSay((string) llGetFreeMemory() + " Bytes.");
}

}


Output:

Object: 41088 Bytes.
Object: 41088 Bytes.

Tested under LSO as well, same results, numbers match, and yes, I lowered the index max to 100 to not overflow.

I believe that indicates at least that llListSort is passed by reference. If my testing is wrong, PLEASE let me know :)
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
04-20-2009 14:29
From: Lazink Maeterlinck
I just ran a simple test, and it looks like built-in functions are passed by reference.
Please try it on the beta grid. With the current implementation in the main grid, if you temporarily use more memory but free it before a swapping point, it doesn't count against your memory limit. You were allowed to temporarily go over the 64K limit for Mono.

Since they want to meter memory usage, they figured they need to check memory usage at all times. This will of course break some existing content, which is why they're running it on the beta grid.

Nothing is ever simple!
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
04-20-2009 14:45
It works the same on the scheduler test sims.

[14:40] Object: 41088 Bytes.
[14:40] Object: 41088 Bytes.

Items inside lists are copied around by reference under Mono when possible. This is why LSL Mono memory benchmarks that try to append only NULL_KEY to a list seem to give improbably high results, the lists aren't getting appended in the traditional way.

See here at about 8:28 for an explanation.

http://wiki.secondlife.com/wiki/User:Babbage_Linden/Office_Hours/2008_09_17
1 2 3