Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to optimize code and when not to.

Domino Marama
Domino Designs
Join date: 22 Sep 2006
Posts: 1,126
01-16-2007 03:44
From: Bobbyb30 Zohari
1 byte?
Are we that desperate to get 1 byte?


On it's own probably not. But the cumulative effect of these optimisations can be significant for some types of scripts. My racing system for example. The more memory I save, the higher the number of lap times that can be recorded per race is. Of course there, finding the right performance / memory balance is important. So as the ones you quoted are slower, I won't be using those this time, but many of the others in this thread do get liberal use in the code :)
Valradica Vanek
Registered User
Join date: 1 Aug 2006
Posts: 78
questions
03-08-2007 09:52
OK, so all the talk about optimization is sweet, but leaves several questions:

1) what is the compiled scipt byte code limit?
2) Where do you find how much your your code is consuming?
3) Is the code memory limit 16K for a script?
4) How do you tell how much memory is being used?
5) What kinds of Compile errors do you see when you exceed the compliled byte code limit.
6) What kinds of errors do you see when you get a memory overflow?
7) Is there one place where this is actually explained for the young uns?

Val (fairly experienced scripter who is just now beginning to encounter these problems)
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
03-08-2007 11:54
From: Bobbyb30 Zohari
rotation a = <0,0,0,1>;//1
//becomes... and saves 8 bytes
rotation b = <0.0,0.0,0.0,1.0>;//2

so rotation a takes more space than rotation b?

That's what people say - LSL uses less memory if you don't make it do int->float conversions. That is, it's cheaper to say 0.0 than it is to use 0 when a float is required.

Personally, I consider that a compiler bug but it's better form to use the correct notation so it's not an annoying bug.

From: Bobbyb30 Zohari
Just curious but would the placement of {}'s affect a scripts speed/memmory?

I'd be surprised if there was a difference. That's more of a parsing thing than a code generation thing.
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
03-08-2007 12:13
From: Valradica Vanek
1) what is the compiled scipt byte code limit?
2) Where do you find how much your your code is consuming?
3) Is the code memory limit 16K for a script?
4) How do you tell how much memory is being used?
5) What kinds of Compile errors do you see when you exceed the compliled byte code limit.
6) What kinds of errors do you see when you get a memory overflow?
7) Is there one place where this is actually explained for the young uns?

1+3) You get 16kb for code+stack+heap
2+4) llGetFreeMemory()
5) Byte code assembly failed -- out of memory
6) Stack/heap collision. You have to be there when it happens to see the error. The script will be stopped but I think the running box will still be a checked. You have to use another script that checks its state to see that it crashed.
7) The (old) wiki

From: Bobbyb30 Zohari
Just curious but would the placement of {}'s affect a scripts speed/memmory?
no
Dalarian Dyrssen
OC Building Disorder
Join date: 15 Apr 2007
Posts: 38
*sighs*
05-02-2007 11:18
Whatever this thread did to my brain, *wonders about this fuzzy feeling*
but I feel much more enlighted about the inner workings of programming languages ;)

Thanks :)
1 2 3 4