Monday 17 March 2008

LSL Listen Mono Testing

I just did some Mono testing specifically with listeners, and came up with some interesting results. First I did a basic ping test. One object would start a timer and say "ping" to another object which would then say "pingback", and the original object would report the time when it received the message back. Averaged over 200 tests, without Mono the ping time was 0.066478 seconds. With Mono, it was 0.088936 seconds. I ran the tests multiple times, switching back and forth between Mono and non-Mono to make sure this difference was caused by Mono and not by other changes in the sim.

Next I took Robby's idea and had one object say "start" then "junk" 500 times then "finish". Another object would start a timer when it got the "start" message and report the time when it got the "finish" message. First, I used an unfiltered listener, so any messages sent on that channel would be forwarded to the script. The sender reported that it sent "finish" 0.600243 seconds after it sent "start". The receiver reported 33.476112 seconds between hearing the "start" and "finish" messages. I then recompiled with Mono and ran the test again. This time all the messages were sent in 0.178058 and received in 44.580690. The sending was over 3 times faster, but the receiving was slower with Mono.

Now I modified the script to only set up listeners specifically for "start" and "finish" messages. Without Mono, they were sent in 0.600193 seconds and received in 0.644574. With Mono, 0.133408 and 0.133169. All these numbers have taught me two important things: 1) USE FILTERED LISTENERS!!! 2) ESPECIALLY USE FILTERED LISTENERS WITH MONO!!!!!

Now comes the fun part. I copied the unfiltered listener so that there were 25 of them. Each of them ran at about the same time as the single listener. With 100, they still ran about the same. With 1000, still the same. With 10000 (I'm serious...screenshot below) it was finally a different story. First, the time the sender reported to send the messages shot up to 1.916057 seconds. From that number, I estimated it would take 10 minutes for the listeners to finish. I waited for 15 minutes, expecting a Linden to show up and wonder what the hell I was doing, and still there was no response from the listeners.Notice "Script perf" is 0 ips. I'm guessing they just haven't updated that to count Mono instructions.

With the filters, there wasn't much of a change until 400 prims (I increased the number of prims differently). At that level, the listeners finished between .133783 and .201377 seconds, but one of them took 45.042740 seconds, which is so close to the time for the unfiltered listeners it almost makes me think the server panicked and just started handing that one script all the messages. I doubt that's the case, though, because then scripts which used filters and as a result didn't have to check the incoming message would experience errors if they started getting unfiltered messages. At 800 prims, the range was .156157 - .224534, again with a single script reporting at 46.228270. At this point, I didn't go further because looking through a log of 800 messages was getting difficult. Looking back at the data from the unfiltered runs, there was similar variance in the times as seen here, but when it is taking 45 seconds it is much less significant.

One final weird behavior that I noticed while recreating these tests for the Jira issue (see below). I went back to the ping test and added filters for "ping" and "pingback". I didn't expect to see any difference, since all the messages sent are "ping" and "pingback" (on different channels, so that is already filtered). Indeed, there was no difference when not using Mono. But with Mono, it took longer! The time increased to 0.101741, which is an increase of about .02 seconds or a 25% increase.

In conclusion, I am definitely going to use filters all the time now. I have created a Jira issue about the performance decreases with Mono. Now what can I test!? :P

16 comments:

Anonymous said...

Here's something else you can test :)

I'm going to make an assumption that your listener scripts did absolutely minimal processing. Am I right?

If so, then we can assume that there's a measurable overhead in figuring out what listeners to give the message to (minimal) as well as firing up the script and calling the listen event (significant).

Listen events are queued, which likely gives rise to a large part of the poor performance of the unfiltered listens, as the "finish message" cannot be processed (and it's time recorded) until all of the other messages have been (minimally) processed.

So what happens with there is more processing going on in the listener? Even something as simple as "Is this message really for me?". As an example, in the case of scripted swords, you cannot listen for messages to make the sword held in the hand visible/invisible by only filtering by the owner, as it is the sheath sending the messages rather than the avatar (ignore for now that you can filter on 'draw' and 'sheath' text). You would then have to have a check for [ if( llGetOwnerKey(id) == llGetOwner() ] or something similar.

I suspect that you will see at least some performance differences if you have some additional processing going on. Imagine a hug script that, upon receiving the "hug [so and so] message" on channel 0 needs to do a sensor ping for [so and so], send them a permission dialog, start the animation, move the avatar into range, etc.

While not all of that processing takes place in the listen event, one curious thing about LSL is that it will queue all chat messages while any part of the script is busy. I believe that the maximum event queue size is 64, but I don't know if that holds for listens.

[Off topic side-note: Control events, by contrast, are not queued. This makes it very hard to create a highly responsive sword script, as you must be *very* careful to not be busy and therefore 'miss' a keystroke. Controls that are pressed while any part of your script is processing are ignored.]

You could probably simulate any of that by simply putting in an llSleep( 0.1 ) call in the listen event when the listener receives one of the "junk" messages.

I'd be interested to know whether adding up the 0.1 second delays and comparing them to the actual time it takes to do the processing has a 1:1 correlation. I doubt it, though I wouldn't expect a huge difference. I'd also love to be able to view the server-side memory usage while the queued events are being stored until they may be processed.

Another thing to test: Chat lag. Make the junk messages sequential counters, and flag "out of sequence" messages. See if the flagged messages occur more frequently with lots of unfiltered listens as opposed to fewer filtered listens.

Interesting tests, Colin! I hope you make a series out of it :)

Colin said...

One thing I thought I noticed before that I just verified is that while all the objects report almost the same time between start and finish, they report in chunks with small but noticeable delays (a second at most) in between. This seems to indicate that when the sim can't handle distributing all the messages, instead of slowing down all the scripts equally it starves some so that it can keep serving others at the full rate. I'm going to look into this more.

Anonymous said...

[url=http://www.pi7.ru/zdorove/1607-pochemu-molodye-mamy-tak-silno-ustayut.html ]Интимная проблема [/url]
Мне 26 лет, с самого детсва каждый день боялась чем-то заболеть. В прошлом году обнаружив у себя какой-то прыщик буквально насиловала врачей, что это сифилис! Все от меня отамхивались, а я умоляла направление на анализ. Я каждый день сдаю какие-то анализы. после чего иасно боюсь. Постоянно фантазирую что больна чем-то.... Я так более не могу!!!!!!!!!!!!!!! Ходила к психологу.... вообще результатов никаких. Что делать????

Anonymous said...

Как говорилось на Seexi.net Ходила на курсы. Не понравилось,много времени занимаются упражнениями,короче как в школе. Класс не очень большой,5 человек,но скучно. Потом занималась сама. Слов знаю много,читаю буквально без словаря.
Разговаривать не могу. Какой-то ступор. Пыталась учить наизусть диалоги. При диалоге фразы из них не вспоминаются! Это стало ещё одной задачей. Читала различные советы. Скайп не люблю. Вообще я интроверт. Мне надо очень хорошо хнать человека,чтобы с ним разговаривать. Но язык надо развязать, для работы. Написала сюда,может кто что-то подскажет.

Anonymous said...

[b]Привет Всем! [/b]
Я Екатерина Игнатюк... и это моя первая для начало запись в этом блоге.
Исходя из теории разумного эгоизма и как настоящая "эгоистка" расскажу немножко о себе любимой.
Я молода, здорова, небогата но стремлюсь, амбициозна, полна сил и энергии.
Живу счастливо, чего и Вам всем желаю.
У меня есть Интернет Клуб http://www.2nt.ru/users/katya (Браки между близкими родственниками возможны ) благодаря которому я наменрена помогать сохранять и улучшать здоровье людям.
Буду рада вас видеть у себя в клубе.

Предлагаю Вам [b][url=http://2nt.ru]секс знакомства в байкальске [/url][/b] и др, с огромным количеством информации по интересующей Вас теме. Для себя я обнаружила много интересного.

Anonymous said...

[b]Привет Всем! [/b]
Я Екатерина Игнатюк... и это моя первая для начало запись в этом блоге.
Исходя из теории разумного эгоизма и как настоящая "эгоистка" расскажу немножко о себе любимой.
Я молода, здорова, небогата но стремлюсь, амбициозна, полна сил и энергии.
Живу счастливо, чего и Вам всем желаю.
У меня есть Интернет Клуб http://www.2nt.ru/users/katya (Зайка моя: выбираем кролика ) благодаря которому я наменрена помогать сохранять и улучшать здоровье людям.
Буду рада вас видеть у себя в клубе.

Предлагаю Вам [b][url=http://2nt.ru]секс знакомства в урюпинске [/url][/b] и др, с огромным количеством информации по интересующей Вас теме. Для себя я обнаружила много интересного.

Anonymous said...

Что в имени тебе моем, ты оцени груди объем. А лес такой загадочный, а слез такой задумчивый Каждый человек имеет право на лево. “Голубой бежит – вагон качается …” Каждая женщина достойна секса, но не каждая – дважды

Anonymous said...

Спасибо понравилось !

Anonymous said...

Спасибо понравилось !

Anonymous said...

Наши специалисты по сертификации и [b][url=http://gortest.su]сертификат на щебень [/url][/b] подготовят полный пакет необходимых документов. Нами производится сертификация широчайшего спектра объектов [b][url=http://gortest.su]сертификат соответствия [/url][/b] любых товаров, услуг, сертификация работ, по любым нормам и стандартам

Anonymous said...

Я не могу его выгнать - ему некуда идти. Но мне каждый день может показаться на первый взгляд, что он меня не ценит. Я его очень люблю. Но знаю, что он полюбил меня недоступную, далекую и ему не принадлежащую, а в данный момент я шага не могу без него сделать. Это уже какая-то зависимость от человека.

[IMG]http://v7em.com/go/vnimanue.png[/IMG]

Anonymous said...

Поздравляю вас Старо-Новым годом, желаю вам в новом году успехов и спасибо что вы находите время поддерживать ваш замечательный блог!

Anonymous said...

Happy Fresh Year[url=http://pavuyume.tripod.com/] everyone! :)

Anonymous said...

Хоть кто-то здравомыслящий остался

Anonymous said...

У Вас до сих пор нет сайта, хотите заказать хостинг, зарегистрировать дешево домен, нужна качественная расктрутка тогда Вам сюда [url=http://yestech.ru/]разработка и продвижение сайтов
[/url]

Anonymous said...

Салон Секреты Красоты предлагает большой выбор классических салонных услуг: парикмахерские услуги, маникюр, педикюр, косметология, перманентный макияж. Мы работаем более 10 лет и придерживаемся принципа соотношения цены и качества обслуживания. Для постоянных клиентов действуют акции и бонусная система. Заходите на наш сайт [url=http://s-krasoti.ru/] ламинирование волос акции
[/url]