lock group updates

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

lock group updates

Post by monte » Tue Apr 23, 2013 1:17 pm

Hi

mApp the mobile app framework I've been working on has code that sets the rect of all objects on a card in a recursive handler. It occurs to me there's probably lots of wasted execution time on groups resizing themselves and resetting scrollbars when each of their children is resized. I think for such a situation a way to lock a group from refreshing itself on MCGroup::resizeparent() and a way to unlock it thus causing resizeparent to happen once at the end would improve performance significantly... what do others think about the idea? Note that lockLocation actually doesn't stop quite a bit of code executing ...

Code: Select all

set the lockUpdates of group 1 to true
-- code that changes lots of child object locations
set the lockUpdates of group 1 to false
Cheers

Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Mon Apr 29, 2013 10:55 am

Hi... not much interest in this obviously

I had a little play with it anyway and the following code moving an object inside a group was about twice as fast with lockUpdates true than if the lockUpdates lines are commented out. On average about 8 ms with lockUpdates and 17 ms without. Not sure if it's worth the trouble but I guess if we are looking at game engines then any object movement optimisations we can provide the better.

Code: Select all

on mouseUp
   lock screen
   put the milliseconds into tSecs
   set the lockUpdates of the owner of btn "test" to true
   repeat 1000
      set the loc of btn "test" to random(the width of this cd),random(the height of this cd)
   end repeat
   set the lockUpdates of the owner of btn "test" to false
   put the milliseconds - tSecs
end mouseUp
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Mon Apr 29, 2013 11:04 am

Oh, and it's about 5 times faster if lock screen isn't on (around 200ms v 1000ms)... but I didn't think that would count because if you care enough about performance to lockUpdates then leaving the screen unlocked would be odd...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Mon Apr 29, 2013 11:10 am

Interesting... I tried with scrollbars visible thinking it would be better performance again and the lockUpdate version was about the same but without lockUpdates was 4 ms faster than without scrollbars...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: lock group updates

Post by malte » Mon Apr 29, 2013 11:57 am

Lots of interest monte. :-)

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Mon Apr 29, 2013 12:04 pm

OK then.. so you think shaving 8 or 9 milliseconds on 1000 object moves for objects inside a group is worth the trouble? Actually it wasn't much trouble... I guess if we're talking games then 8 or 9 milliseconds is the difference between keeping up with the frame rate and not...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Location: Thailand
Contact:

Re: lock group updates

Post by dave_probertGA6e24 » Mon Apr 29, 2013 12:12 pm

I can't really comment usefully on the subject Monte, but I, for one, am interested in your comments and what you are doing.
It sounds really good that you are looking at ways to speed up LC over and above the current improvements. Keep persevering and I'm sure everyone will appreciate it.

Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Mon Apr 29, 2013 12:17 pm

Actually some more playing with this and for some reason it takes the same amount of time for the script to move an object that isn't grouped as it does without lockUpdates... I can't imagine why... anyway... with the change it seems it's actually faster to have your objects in groups than not. I guess grouping is handy for layers etc in games...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: lock group updates

Post by malte » Mon Apr 29, 2013 1:13 pm

Hi Monte,

every millisecond counts. In any application that works with many objects. One example as you said is games, where you do not only do this once, but repeately over and over again. There are other apps I can think of (realtime graphs for example) where the drawing time might be brought down quite a bit.

Cheers,

Malte

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Mon Apr 29, 2013 1:33 pm

Right... I guess there could easily be many objects in a complex chart and I like charts that move when you fiddle with sliders etc so it would smooth out that too I guess...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Wed May 01, 2013 11:17 am

Just bumping this to see if @runrevmark has comments.. I can send a pull request if you want to see what I've done...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: lock group updates

Post by LCMark » Thu May 02, 2013 11:14 am

I need to do some more thinking on this one - I can see the utility (particularly with the rise in custom controls which have to manipulate lots of controls inside them). If you send a pull request I can perhaps more easily see how you've got it working and thus see if it could cause any issues.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: lock group updates

Post by monte » Thu May 02, 2013 11:49 am

sent

Your message contains 4 characters. The minimum number of characters you need to enter is 10.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Locked

Return to “Engine Contributors”