Are listeners actually expensive, or is this a myth?

Creating scripts
User avatar
Mike Lorrey
Posts: 258
Joined: Sun Sep 04, 2016 5:40 pm
Has thanked: 59 times
Been thanked: 173 times

Re: Are listeners actually expensive, or is this a myth?

Post by Mike Lorrey »

Tess Juel wrote:
Sat Aug 21, 2021 4:25 pm
IntLibber Brautigan wrote:
Sat Aug 21, 2021 3:30 pm
In device 1:

Code: Select all

integer setupchan = 999;
integer chan = (integer)llFrand(999999);
One question about this snippet. In SL it's consdiered good practice to always use negative channels for scripts so it would be

Code: Select all

integer setupchan = -999;
integer chan = (integer)llFrand(-999999);
Is opensim different there?
You are correct, negative channels are recommended, though most novices dont get them, but thats a separate topic. However! it was claimed years ago that negative channels could not be listened into by others, which is blatantly false.
User avatar
Mike Lorrey
Posts: 258
Joined: Sun Sep 04, 2016 5:40 pm
Has thanked: 59 times
Been thanked: 173 times

Re: Are listeners actually expensive, or is this a myth?

Post by Mike Lorrey »

Tess Juel wrote:
Sat Aug 21, 2021 4:38 pm
Oren Hurvitz wrote:
Sun Jul 11, 2021 7:15 am
The usage cost appears to be pretty low, at least if not too many messages are being sent. Sure, OpenSim has to go over all of the potential listeners, but it can probably do this in a few ms. It only becomes a problem if you have a large number of listeners (hundreds?), or if you send many messages per second.
Tell me if I understand this right. Let's say I have a master switch that turns on and off street lights across the entire sim. Or a master texture changer that switches between seasonal foliages for all trees in the sim. There may well be hundreds, maybe even more than a thousand receivers but there won't be a message sent every day or even every month. Are all those open listens still likely to cause problems?
Yes, the main reason to turn off listens when not in use is that a) sloppy scripters tend to use the same channels for a lot of things so you get a lot of cross-talk between different types of scripts, hence the random channel code I posted, b) in regions where there are multiple content owners like a sim with tenants, you definitely don't want everyones scripts talking to each other unintentionally. Using the channel randomizer code makes sure that the fewest number of scripted objects will hear message chatter, so you'll get the least lag when they are talking to each other.
These users thanked the author Mike Lorrey for the post (total 3):
Ilan TochnerTess JuelChristine Nyn
User avatar
Christine Nyn
Posts: 22
Joined: Sat Mar 07, 2020 10:20 pm
Has thanked: 35 times
Been thanked: 34 times

Re: Are listeners actually expensive, or is this a myth?

Post by Christine Nyn »

To add to Mike's very useful overview:

Positive channels can be accessed directly from chat either by using, for example /21 <your message>, or as an embedded part of a gesture. Negative channels can only be accessed by script. Thus there exists a chance that positive channels used for script control could be unintentionally interfered with by others within chat range of the scripted object. Negative channels range from -1 to -2147483646, over two thousand million possibilities, so as long as a fairly high randomly generated negative channel is used the chances of it being listened to or accidentally duplicated on a region are so small as to be almost non-existent.
These users thanked the author Christine Nyn for the post (total 2):
Tess JuelGraham Mills
Post Reply