Jump to content

Updating a list rapidly


animats
 Share

You are about to reply to a thread that has been inactive for 1769 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I doubt there's a faster way, but I'll ask anyway.

Is there any way to update a single element in a list, by index, that's faster than llList2List? I know, lists are immutable and a new one has to be created for every update. I was hoping that, just perhaps, there was a built in Mono optimization for

lst = llList2List(lst, [n], ix, ix);

which could, if recognized by the compiler as a special case, be done very efficiently. But there's not. Making 1024 random updates to a list of 1024 integers takes 4 seconds in Animesh 1 on the beta grid and 8 seconds in my home sim. Because, of course, it's recopying the whole list for every update.

Is there any trick for manipulating large arrays in LSL?

(I'm trying to write an A* algorithm. Doing this in LSL is like pounding a screw.)

Edited by animats
Link to comment
Share on other sites

Some test results:

[23:57] Array update timing test 0.3: Timing tests.
[23:57] Array update timing test 0.3: Fill array of 1024 in 2.313786 secs.
[23:57] Array update timing test 0.3: 1024 updates to list of 1024 elements in 4.798160 seconds.
[23:57] Array update timing test 0.3: Fill array of 512 in 0.421613 secs.
[23:57] Array update timing test 0.3: 1024 updates to list of 512 elements in 2.094694 seconds.
[23:57] Array update timing test 0.3: Fill array of 256 in 0.088729 secs.
[23:57] Array update timing test 0.3: 1024 updates to list of 256 elements in 1.275658 seconds.
[23:57] Array update timing test 0.3: Fill array of 128 in 0.039960 secs.
[23:57] Array update timing test 0.3: 1024 updates to list of 128 elements in 0.670230 seconds.
[23:57] Array update timing test 0.3: Fill array of 64 in 0.039129 secs.
[23:57] Array update timing test 0.3: 1024 updates to list of 64 elements in 0.674368 seconds.
[23:57] Array update timing test 0.3: Fill array of 32 in 0.000000 secs.
[23:57] Array update timing test 0.3: 1024 updates to list of 32 elements in 0.601021 seconds.
[23:57] Array update timing test 0.3: Done

Performance is independent of list length up to 128. Then it gets worse, linearly. So using multiple lists no longer than 128 seems to be an useful optimization.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1769 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...