Bug 22274

Summary: Remove support for Attr nodes for ~600k memory savings on membuster
Product: WebKit Reporter: Maciej Stachowiak <mjs>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: alice.barraclough, ap, cdumez, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   

Description Maciej Stachowiak 2008-11-14 19:56:58 PST
If we remove support for Attr nodes in the DOM, we could save 3 words per attribute, as follows:

1) Remove the Attr pointer from Attribute. (one word for the pointer)
2) Make Attribute not be refcounted any more. (one word for the refcount)
3) Change NamedAttrMap to hold a Vector<Attribute> instead of Vector<RefPtr<Attribute> > (one word for the pointer in the vector.

There could be additional savings from reducing fragmentation.

Other browsers do not support Attr nodes and have stated they do not plan to support them and would like them removed from standards, so it should not be a compatibility risk to do this.
Comment 1 Alexey Proskuryakov 2008-11-15 04:39:32 PST
Removing Attr node support may break XPath pretty badly (I haven't looked into XPath implementation again to be sure, but I think that many practical cases depend on Attr nodes being supported).
Comment 2 Sam Weinig 2008-11-15 05:05:38 PST
(In reply to comment #1)
> Removing Attr node support may break XPath pretty badly (I haven't looked into
> XPath implementation again to be sure, but I think that many practical cases
> depend on Attr nodes being supported).

Can you expand on this?  Does this break functionality in Firefox?
Comment 3 Alexey Proskuryakov 2008-11-15 13:53:12 PST
I just remember that XPath was pretty big on creating Attr nodes from attributes, which is why I had to optimize that code path. If anything breaks, tests will tell.

I'm not sure how what Firefox has to do with this - it's just an implementation detail of XPath, it can certainly be special-cased to use custom attribute values instead of Attr nodes internally.
Comment 4 Alexey Proskuryakov 2008-12-12 03:45:27 PST
(In reply to comment #0)
> Other browsers do not support Attr nodes

In both Opera and Firefox 3, I'm getting the same Attr node when calling getAttributeNode() twice in a row, so it seems that they are referenced in DOM. What is the difference from WebKit in their Attr node support?
Comment 5 Alexey Proskuryakov 2009-01-08 00:13:42 PST
As discussed on IRC, this bug is not valid, because other browsers do support Attr nodes. It may be possible to make use of the fact that these nodes are rarely used though.
Comment 6 Lucas Forschler 2019-02-06 09:03:51 PST
Mass moving XML DOM bugs to the "DOM" Component.