Speed improvements

50 views
Skip to first unread message

Matt Brubeck

unread,
Mar 31, 2009, 2:36:38 AM3/31/09
to ActiveJS
I've been doing some aggressive optimization in order to make large
find() operations faster on mobile devices. I've currently got about
a 3x speed increase for a "SELECT *" on a 100-row, 15-column table:
http://github.com/mbrubeck/activejs/commits/master

Most of my changes should be safe (I haven't tested them rigorously
yet, but they pass all the unit tests). But two of them introduce
incompatibilities, and might not work for everyone as-is:

http://github.com/mbrubeck/activejs/commit/dbb05530bb3c5b37a35b01de212109153eb23e90
Suppress all "set" notifications triggered by the model constructor.
This is a big performance improvement, but we should probably have a
way to turn them back on for people who rely on observe('set').

http://github.com/mbrubeck/activejs/commit/6cd1f9e1092c9953928340ae38f37aad3969a9b7
Remove the ability to pass a field definition ({type:..., value:...})
as a value to the model constructor. I couldn't find any code or
documentation that used this, or any reason you would want to (since
the "type" was just ignored).

See my commit log for more details and commentary. I think I've
reached about as much performance as I'm going to get with local
optimizations to existing functions. If I need any more speed, I'll
probably try some more radical surgery, like eliminating some steps
from the iterable->iterate->build->constructor pipeline.

Ryan Johnson

unread,
Mar 31, 2009, 12:45:49 PM3/31/09
to acti...@googlegroups.com
Wow! Fantastic. I will take a look at the changes. I do depend on
notify('set'), but I think we could optimize it a little different
(off the top of my head):

if(this._observers['set'] && this._observers['set'].length > 0)
this.notify('set',key,value);

Anyway, I started doing some optimizations a while back, and while the
code did get uglier and more verbose it is awesome to see the speed
gains. I might have more quibbles, but I'll make sure your changes get
into the trunk ASAP. - Ryan
Reply all
Reply to author
Forward
0 new messages