Bug 75333 - Reduce memory used by NamedNodeMap.
Summary: Reduce memory used by NamedNodeMap.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-28 19:09 PST by Andreas Kling
Modified: 2011-12-28 19:56 PST (History)
2 users (show)

See Also:


Attachments
Proposed patch (1.31 KB, patch)
2011-12-28 19:28 PST, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2011-12-28 19:09:57 PST
The vast majority of attribute maps contain 4 or fewer attributes. Furthermore, an element with 0 attributes doesn't need an attribute map at all.
With this in mind, we can give the attribute vector an inline capacity of 4 and avoid having the initial append() grow to 16 entries capacity.
Comment 1 Andreas Kling 2011-12-28 19:28:51 PST
Created attachment 120714 [details]
Proposed patch
Comment 2 Andreas Kling 2011-12-28 19:35:26 PST
For reference, attributes per NamedNodeMap (Alexa top sites):

No NamedNodeMap allocated: 76.579%
0: 0.073%
1: 22.046%
2: 1.219%
3: 0.039%
4: 0.038%
5: 0.002%
... and then dwindling downwards up to 13 attributes.
Comment 3 Sam Weinig 2011-12-28 19:37:58 PST
Comment on attachment 120714 [details]
Proposed patch

Nice. r=me.
Comment 4 Andreas Kling 2011-12-28 19:56:32 PST
Comment on attachment 120714 [details]
Proposed patch

Clearing flags on attachment: 120714

Committed r103791: <http://trac.webkit.org/changeset/103791>
Comment 5 Andreas Kling 2011-12-28 19:56:41 PST
All reviewed patches have been landed.  Closing bug.