Heap/Stack mysteries (questions for Lindens!)
|
Madox Kobayashi
Madox Labs R&D
Join date: 28 Jun 2003
Posts: 402
|
08-07-2003 06:45
I'm hoping a Linden will come and answer some questions about heap/stack. I'm making a script that is banging into the heap/stack collision error very reproducibly. So to better avoid this situation, I want to understand how it works: - Does the code segment lie in the heap or the stack? - Is the code byte-compiled in some custom way or not? IE: will removing braces and extra spaces and comments free up some heap/stack space?  - When variables go out of scope is the heap cleared up right away or is there some kind of garbage collection process? - Same question with respect to return values and temporary lists (ie: myList = myList + ["blah"]; or myString = llGetSubString(myString,1,5); ) Bonus questions: I have 2 functions that purely perform math operations, and I loop over them 100 times. I expect it to just plow through its cycles, but I find that each itteration is taking a couple seconds each.  So: - Is there any delay inherant in llPow() or llFloat() and the like? - Is there any delay inherant in function calls? - Is there any delay inherant in retrieving variable data when the heap is large as opposed to when it's small? Followups: - Can we get a llMaxHeapStackSapce() and llCurHeapStackSpace() call ? - Can we get a llGarbageCollect() call if applicable?
_____________________
Madox Kobayashi
|
Madox Kobayashi
Madox Labs R&D
Join date: 28 Jun 2003
Posts: 402
|
08-08-2003 11:24
I see there is some Linden activity here today. So figured I'll bump and hold my breath 
_____________________
Madox Kobayashi
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
08-08-2003 11:55
If LL could post these Id love them forever! Heh, but all mushyness aside, there are some automatic/non-user controllable delays in LSL: From: someone Cory Linden:
Sleep blocks script executon and individual scripts are not multithreaded, so during sleep, the script doesnt do anything. This should be in the docs, but real quick, here are the major delayed function calls:
llSetTexture(); llScaleTexture(); llOffsetTexture(); llRotateTexture(); llSetPos(); llSetRot(); (these all delay .2 seconds per function call)
llInstantMessage(); (10 seconds) llEmail(); (20 seconds)
llSay(); doesnt currently add a delay
Hopefully 1.1 shortens the delays of some of these, or the implimentation of Havok 2 decreases the server-side lag enough to get rid of the delays altogether. I hope this helps! -Chris
|
Radium Lumin
Pixel's Mom
Join date: 22 Jul 2003
Posts: 23
|
08-08-2003 12:44
Some of you have met me, and seen my creation, 'Pixel'. Pixel is an 'Intelligent Toy', the first in his line. He's getting pretty smart. His brain is a complex script, now over 600 lines. I just ran hard into the stack-heap error. Pixel's script now gets it immediately upon startup. I mean, before the first line of code is executed. Christopher Omega was very helpful in trying to debug the script. We eventually decided that I was just using too many variables, and that my script had grown too big for LSL. Ouch. Pixel needs to be smarter before I can expect to sell him. What to do? Well, I'm going to go back through his script, paring out as many variables as possible, and making as many of them local as I can. Chris gave me some pointers on reducing memory usage. Also, I may need to break the script up into several cooperative scripts that talk to one another. This may be hard to do, because of the amount of data that is passed around. We'll see, because I really have no choice. Perhaps we can get the Lindens to give us more more memory for our scripts in 1.1? Think about it... As we learn to script better, we will naturally create more complex scripts. More complex scripts leads to more complex behaviour for our creations. More 'wonders.' But really, I just want Pixel to be the kind of toy I envision him as. 
|
Madox Kobayashi
Madox Labs R&D
Join date: 28 Jun 2003
Posts: 402
|
08-08-2003 13:54
Hey, I might have something to help you. I recently made a script that needed over 200 integer variables. I worked out a system of storing all those variables using a handful of rotation variables (about 13 of them). So if your variable needs are purely numeric, this might help you. I plan to post the script segment here as the first public offering from Madox Laboratories 
_____________________
Madox Kobayashi
|
Darwin Appleby
I Was Beaten With Satan
Join date: 14 Mar 2003
Posts: 2,779
|
08-08-2003 13:56
Well, we hope with Havock 2 we can make some bigger scripts, cuz I want to get some AI out there too.
But actually, I think the 10 second delay on IMs is a saftey feature so you can't bug places. Correct me if I'm wrong but IMs cause minimal lag and a 10 sec delay is a little much considering it's more than changing textures...
_____________________
Touche.
|
Ama Omega
Lost Wanderer
Join date: 11 Dec 2002
Posts: 1,770
|
08-08-2003 17:01
I'm not sure as to how Havoc 2 will increase the possible script size? maybe I missed something.
|
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
|
08-08-2003 18:58
Havok 2 will restore thinning hair, whiten your teeth, and let you lose weight without dieting or exercise.
|
Darwin Appleby
I Was Beaten With Satan
Join date: 14 Mar 2003
Posts: 2,779
|
08-08-2003 19:15
Hah Jake.
Ama, what havock will do is simply reduce lag caused by physical objects thus opening room to decrease delays.
_____________________
Touche.
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
08-08-2003 23:37
I talked to Ben about how SL will be bettered by Havok 2, and he replyed with quite an amount of detail. Points: 1: The BIGGEST strain on the servers is physics. 2: The BIGGEST strain on physics is avitars (which is why they limit how many can be in a sim) 3: The MAIN improvement in Havoc 2 isnt its better physics handling, but it's major decrease in computational resources needed to actually impliment physics. (Meaning Havok 2 speed == 130% * Havok 1 speed (about 30% decrease in needed CPU cycles)) 4: The current physics implimentations are very buggy, and tend to crash servers when stressed, Havok 2 will alleviate most of this, but crashing sims will still be possible. 5: Less stress on the sim means MORE features LL is able to implimnt, LESS lag we will all experiane, and MORE realism using physics. 6: Since physics will be less of a load on the sims, MORE people hen ever b4 can be on the same sim at once, and having more people at an event, or crowding an area will yield much FASTER client/server performance then what happens now. All in all, implimenting Havok 2 will literally revolutionize SL for the DEFINATE better. I actually encourage LL to NOT rush Havok 2, look at it like this: If they did impliment the current version of Havok 2 in SL, all your hollow, cut, prims, and all tori, spheres, and tubes will eiather cease to exist, or crash any server theyre in. The more time LL spends making Havok 2 compatible with SL the better, we dont want our entire world collapsing because we rushed them with the implimentation. So there -Chris
|
Ama Omega
Lost Wanderer
Join date: 11 Dec 2002
Posts: 1,770
|
08-08-2003 23:46
From: someone we hope with Havock 2 we can make some bigger scripts Was just commenting on this line Darwin.  It sounded like you were saying Havok 2 would make bigger scripts possible. I think now you are just hoping that bigger scripts are possible by the time Havok 2 is implemented, so that you can create the AI you want.
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
08-08-2003 23:52
Well, it could, technically, Ama, since with Havok 2, server side CPU and memory usage will go down, the limits for scripts might go up.
|
Ama Omega
Lost Wanderer
Join date: 11 Dec 2002
Posts: 1,770
|
08-09-2003 09:49
Yup Chris and hence my post "maybe I missed something", just kinda wondering where that came from ya know.
|