Bug 75315

Summary: Reduce memory used by SpaceSplitString.
Product: WebKit Reporter: Andreas Kling <kling>
Component: DOMAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, dglazkov, koivisto, sam, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch
none
Proposed patch v2 none

Description Andreas Kling 2011-12-28 08:53:31 PST
WebCore/dom/SpaceSplitString, used primarily for element class names, is quite wasteful memory wise. We could get massive gains with some simple trickery..
Comment 1 Andreas Kling 2011-12-28 09:02:47 PST
Created attachment 120679 [details]
Proposed patch
Comment 2 Sam Weinig 2011-12-28 09:39:53 PST
Comment on attachment 120679 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=120679&action=review

> Source/WebCore/dom/SpaceSplitString.h:75
> +            Vector<AtomicString>* m_vector;

This Vector used to have an inline capacity of 8, which I remember being a speedup at one point.
Comment 3 Andreas Kling 2011-12-28 13:10:21 PST
I instrumented the Alexa top sites to find out how many substrings we normally find in the class attribute, here are the results (number of substrings: percentage of class attributes):

1: 64.20%
2: 25.64%
3: 6.15%
4: 2.28%
5: 0.95%
6: 0.35%
7: 0.21%
8: 0.13%
9: 0.06%
10: 0.08%
11: 0.03%
12: 0.01%

Given this data, I think we can reduce the inline capacity down to 2 where we'd save good amounts of memory and still cover 90% of cases.
Comment 4 Andreas Kling 2011-12-28 15:47:11 PST
Created attachment 120705 [details]
Proposed patch v2
Comment 5 Sam Weinig 2011-12-28 19:39:38 PST
Comment on attachment 120705 [details]
Proposed patch v2

I like it.
Comment 6 WebKit Review Bot 2011-12-28 19:46:34 PST
Comment on attachment 120705 [details]
Proposed patch v2

Attachment 120705 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10993749

New failing tests:
http/tests/inspector/resource-tree/resource-tree-document-url.html
Comment 7 Andreas Kling 2011-12-28 19:54:53 PST
Comment on attachment 120705 [details]
Proposed patch v2

Clearing flags on attachment: 120705

Committed r103790: <http://trac.webkit.org/changeset/103790>
Comment 8 Andreas Kling 2011-12-28 19:55:03 PST
All reviewed patches have been landed.  Closing bug.