Jump to content
Sign in to follow this  
animats

Updating a list rapidly

Recommended Posts

Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...