If There Is Nobody There, Why Is The Script Running? (UPDATED: Linden Feedback)
I'd emailed in my question and got a response today. The response is below the line and italicized.
It occurred to me while I was discussing the Reuters SecondLife Bureau's display that devices which are taking advantage of web services may be constantly polling for data... when no one is there. I don't know how much stress this puts a SecondLife simulator under, but it seemed to me that the devices should only be on if at least one avatar is present. In some circumstances, devices will need to run without avatars present - for serving vendors (as much as I detest those) as an example. But for informational purposes - is it necessary?
Operating under the premise that the Linden Scripting Language's
llSensorRepeat
might be more efficient than polling web services or other things all the time, I tossed together some code:
state_entry()
{
llSensorRepeat("","",AGENT,10.0,PI,30.0);
}
sensor(integer total_number)
{
//Do your scripted stuff
}
no_sensor()
{
// Do Nothing
}
Basically, this sits and polls every 30 seconds until an avatar shows up within 10 meters of the object. What is unfortunate is that it does use simulator resources while doing this - but the question of whether this code is useful depends on:
Will sitting and polling to see if an avatar is present take less resources than sitting there and doing whatever else the object does?
I think as more web services are used, polling may become more efficient - but I'm not sure. Does anyone have any data to support or debunk this? IM Nobody Fugazi in world or leave a comment below if you have answers...
---------------------------------------------------------------------------------
Response from Kelly Linden:
It really does depend on what the script is doing. A couple of llHTTPRequests almost assuredly cause less load than an llSensorRepeat. But where is the line drawn? If you can halt a dozen or more requests by using a single sensor that could be a win, but I'm not sure. If you can replace the sensor with a button (touch) to start, or a collision (llVolumeDetect) that would probably be even better since these events do not continually run. However if you have to put a sensor in every object that is making one or two http requests every 30 seconds there probably isn't a whole lot of gain, performance wise.
Unfortunately I do not have hard data, although I would be interested in seeing any testing results done in this area.
---------------------------------------------------------------------------------
Yeah, the button makes more sense to me, but then you have to get people to click things... which is harder than it looks sometimes...

WOW a usefull sensor script idea
I agree with kelly, touch is better, otherwise what you have is a 'popup'. i prefer the opt-in protocal of touch based activation. but use the sensor to note if the AV leaves the area. When i come to including any streamming stuff, i'll definatly look to optimizations like the above.
on a similar note, i'd like AV's to be able to attend an event invisably(i mean without their lag inducing avatar, just a nametag for interaction)
do you have any other performance enhancing notions? e-mail me cuz i don't know how often i'll get back to this site.
thanks.
I prefer touch.
Unfortunately, it's very difficult to get people to click things. It's as if they are afraid of getting their mouse dirty.
Honestly, though, I think that the LSL should have a function you can toggle for just this to happen - where it turns off when there's no one around. Plenty of sims could benefit.
touching
part of the problem is the default notify on change money being set at 10L. I'd immediatly set mine to zero (a touching sensor could extract 9L+9L+9L...till you're broke :( !!
The other is some unnerving green linden dollar sign your cursor inexplicably gets turned into fortelling whatever you click will cost? what's a noobknow?
It ist not taking much resources
I understand the llSensorRepeat as a task of a timer.
The system sets a timer to the given amount of time, here 30 seconds. Then the process ist going to sleep like in every other (realtime) OS. It is not using any resources, the countdoen of the timer is a task for the OS which is done automaticly, without any resource consuming.
The amount of cycles for things done by the OS in only one second is some millions instructions, so the time for example of 5, 10 or 30 secons is an eternity.
When it awake after this 30 seconds, it does it work an after that it is going to sleep again for an eternity.
I believe that a http-Request is more resource-consuming because it needs to do the Internet-Connections, the transport, the http-request, the answering, etc, etc.
When i have time, i will test it.
regards
Post new comment