[webkit-dev] JS binding wapper pointers: inline vs. separate hash table

Maciej Stachowiak mjs at apple.com
Wed Oct 1 10:54:21 PDT 2008


On Oct 1, 2008, at 10:50 AM, Geoffrey Garen wrote:

>>> If we believe that JS wrappers are relatively uncommon, we can  
>>> store them in a Node's "rare data" structure, and bloat only those  
>>> uncommon nodes that have JS wrappers.
>>
>> Depending on exactly how common they are, this could be more net  
>> memory use, if it causes Nodes to have a NodeRareData structure  
>> that wouldn't otherwise.
>>
>>> If we believe that JS wrappers are relatively common, we can store  
>>> them directly in a Node, since putting them in a hashtable is net  
>>> more memory use.
>>
>> I think only a minority of nodes have wrappers, but on at least  
>> some pages it is likely to be a sizable minority. I did not measure  
>> though - should have.
>
> I should also mention Sam's suggestion, which I think is pretty  
> good: All HTMLElements (or perhaps all Elements) get embedded  
> pointers to their wrappers, since JavaScript traversal of a document  
> is relatively common. All other DOM objects, including generic  
> nodes, use a hash table.

That would probably cut the memory use significantly. On the other  
hand I bet there are some large pages where few of the nodes ever get  
a JS wrapper in the lifetime of the page (such as cnn.com, slashdot,  
or the Wikipedia page I cited).

To make the right tradeoff we'll also need an estimate of the speed  
benefit.

Regards,
Maciej



More information about the webkit-dev mailing list