• All submissions to this site are governed by Second Life Project Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.
Issue Details (XML | Word | Printable)

Key: SVC-1341
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Babbage Linden
Reporter: davie zinner
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
2. Second Life Service - SVC

Mono beta: Large empty loops cause sim to stall.

Created: 30/Jan/08 02:57 AM   Updated: 17/Mar/08 07:54 PM
Return to search
Component/s: Scripts
Affects Version/s: Mono Beta
Fix Version/s: Mono Beta

Issue Links:
Relates
 

Linden Lab Issue ID: DEV-11852


 Description  « Hide
This script reports how long it takes to call an empty function 10000 times. In LSL it works as you would expect, showing that it takes about five or six seconds to make those 10000 calls. In Mono, it reports about 0.02 seconds regardless of how many calls made to the dummy function. Set i arbitrarily high and it still takes about 0.02 seconds as if the whole while loop were optimized clean out of existence. That's surprising... or suspicious.

dummy()
{
}

default
{
state_entry()
{
float t0 = llGetTime();

integer i = 10000;
while (--i >= 0) { dummy(); }

llOwnerSay("llGetTime() delta = " + (string)(llGetTime() - t0));
}
}

Output in LSL when i = 10000: llGetTime() delta = 5.138102

Output in Mono for any value of i: llGetTime() delta = 0.022538



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
CrystalShard Foo added a comment - 30/Jan/08 03:21 AM
The result of 0.02 looks more like the first execution of the script after you save it. If you click reset, the script will return 0.00 on all subsequent presses.

I've tried to tweak this a little by adding "return 1+1;" into the code and having the function return an integer. This has raised the execution time to an initial 0.177 and an average of 0.066 on resets.

I wouldn't really call this suspicious, I'd call this a major improvement - Mono is far more efficient at what it does then the original LSL VM.


Babbage Linden added a comment - 30/Jan/08 04:58 AM
This is consistent with our benchmarking results. We've seen Mono run up to 220 times faster than LSL2 when running a Mandlebrot generation benchmark. I think you've found a case where the speedup is even higher at around 250x.

davie zinner added a comment - 30/Jan/08 06:40 AM
Well, not exactly. The empirical results showed O compared to O(1), which is an infinite speed-up. There's something about that loop that makes it appear to take constant time. On further experimentation, when I run this:

dummy() { }

default
{
state_entry()
{
float t0 = llGetTime();

integer i = 2147483647;
while (--i >= 0) { dummy(); }

llOwnerSay("llGetTime() delta = " + (string)(llGetTime() - t0));
}
}

it pegs the script time meter in the statistics bar for about 45 seconds (my sincere apologies to my fellow residents in that same region), then the script finally gives the answer of 0.02 seconds elapsed time. Maybe llGetTime() gets dizzy during this unthrottled loop and doesn't update properly. Maybe we need a throttle for this?


Lex Neva added a comment - 30/Jan/08 08:48 AM
That makes me pretty suspicious of llGetTime(). llGetTime() is critical for many of my scripts, so it's important that it works properly.

Creem Pye added a comment - 30/Jan/08 09:46 AM - edited
I just tried davie zinner's 2147483647-iteration example, but replaced llGetTime() with llGetTimeOfDay(); the difference in llGetTimeOfDay() is consistently around 35s, which seems to be correct, considering the sim's time dilation. So it looks like llGetTime() is at fault.

Day Oh added a comment - 30/Jan/08 10:18 AM
Is that confirmed? Should we change the issue's name to suit?

Scouse Linden added a comment - 04/Feb/08 10:58 AM
Changed title to be more appropriate