Re: nsGenericElement::InsertBefore performance

Boris Zbarsky <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
Andreas Pflug wrote:
> So you believe nicely written code would be 100 times faster?

I think 10x faster should certainly be doable.  100x I doubt, as things stand.

> So if stuff is reused, why does it take 20k memory and 5ms to create a 
> simple reference?

I have no idea why 20k, to be honest.  It doesn't feel like it should be that 
much for your use case, and I'd love to see a breakdown of the usage.

For the rest, you're not creating a reference but a tree of references, and then 
you're creating a separate tree of layout objects for them.  The basic issue is 
that you want to allow maximal sharing while at that same time allowing the 
shared things to diverge from each other as the DOM is mutated.  That means they 
can't just be pointers to a shared object; they have to be object wrappers 
forwarding various stuff, which can fault to become heavyweight.

The major win with the prototype system comes from sharing attributes with the 
prototype element, in the end.  If all you have are nodes without much in the 
way of attributes (like a lot of the calendar wrapping boxes), it doesn't help 
that much.

> I must be missing something. Producing 22 lightweight XUL elements takes 
> 5 ms?

Um.  If you'd cared to actually read my post with a breakdown of what takes the 
5ms you wouldn't be asking this question...  But wait!  You did, based on what 
you write below.  So what's the point of this question, if you and I both know 
the answer is "no"?

> Refererencing your old mail, you found a lot of time is spent in the 
> constructor, why is it re-executed?

Because that's the point of the constructor:  It's a bit of script the XBL 
binding defines that is executed every time the binding is attached.  If you 
don't want that to happen... don't put anything in the constructor!

> Why is "loading the XBL bindings" re-executed?

"loading" in this case is just a hashtable lookup on the URI after the first 
binding load.  It's re-executed because the binding needs to be attached to the 
node, and what's associated with the node is just the binding URI (via style) to 
start with.

-Boris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.