Bug 117715 - Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableStylePropertySet.
Summary: Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Alexis Menard (darktears)
URL:
Keywords:
: 118013 (view as bug list)
Depends on: 117481 119444
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-17 13:48 PDT by Alexis Menard (darktears)
Modified: 2013-08-02 06:54 PDT (History)
10 users (show)

See Also:


Attachments
Patch (67.30 KB, patch)
2013-06-17 13:54 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion (704.24 KB, application/zip)
2013-06-17 15:17 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2 (580.55 KB, application/zip)
2013-06-19 21:43 PDT, Build Bot
no flags Details
Patch (67.83 KB, patch)
2013-06-20 12:17 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch (66.16 KB, patch)
2013-06-21 15:17 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch (68.65 KB, patch)
2013-07-31 10:54 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch for landing (69.05 KB, patch)
2013-08-01 04:39 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexis Menard (darktears) 2013-06-17 13:48:46 PDT
Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableStylePropertySet.
Comment 1 Alexis Menard (darktears) 2013-06-17 13:54:33 PDT
Created attachment 204853 [details]
Patch
Comment 2 Alexis Menard (darktears) 2013-06-17 13:57:52 PDT
(In reply to comment #1)
> Created an attachment (id=204853) [details]
> Patch

#117481 is needed for it to entirely work but I'd like to get a measurement on what are the improvements on internal Apple membuster if possible (as-is it should work for testing purposes). Anybody to help me please?
Comment 3 Build Bot 2013-06-17 15:17:53 PDT
Comment on attachment 204853 [details]
Patch

Attachment 204853 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/857435

New failing tests:
fast/css/transform-inline-style.html
transitions/color-transition-rounding.html
fast/dom/CSSStyleDeclaration/transition-property-names.html
fast/css/transform-inline-style-remove.html
media/video-zoom.html
transitions/transitions-parsing.html
fast/repaint/table-cell-collapsed-border-scroll.html
fast/css/shorthand-mismatched-list-crash.html
Comment 4 Build Bot 2013-06-17 15:17:54 PDT
Created attachment 204861 [details]
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-04  Port: mac-mountainlion  Platform: Mac OS X 10.8.3
Comment 5 Alexis Menard (darktears) 2013-06-18 05:35:46 PDT
(In reply to comment #3)
> (From update of attachment 204853 [details])
> Attachment 204853 [details] did not pass mac-ews (mac):
> Output: http://webkit-queues.appspot.com/results/857435
> 
> New failing tests:
> fast/css/transform-inline-style.html
> transitions/color-transition-rounding.html
> fast/dom/CSSStyleDeclaration/transition-property-names.html
> fast/css/transform-inline-style-remove.html
> media/video-zoom.html
> transitions/transitions-parsing.html
> fast/repaint/table-cell-collapsed-border-scroll.html
> fast/css/shorthand-mismatched-list-crash.html

Expected failures due to 117481
Comment 7 Andreas Kling 2013-06-19 07:01:10 PDT
Comment on attachment 204853 [details]
Patch

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

> Source/WebCore/css/StylePropertyShorthand.cpp:626
> +typedef HashMap<CSSPropertyID, Vector<StylePropertyShorthand> > longhandsMap;

Couldn't we just store pointers to StylePropertyShorthand here instead of the full objects?
They are create-once-live-forever anyway, right?

> Source/WebCore/css/StylePropertyShorthand.cpp:627
> +const Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID propertyID)

This should return a const Vector& instead, so call sites don't have to make a copy.
Comment 8 Build Bot 2013-06-19 21:43:13 PDT
Comment on attachment 204853 [details]
Patch

Attachment 204853 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/880413

New failing tests:
fast/css/transform-inline-style.html
transitions/color-transition-rounding.html
fast/dom/CSSStyleDeclaration/transition-property-names.html
fast/css/transform-inline-style-remove.html
transitions/transitions-parsing.html
fast/css/shorthand-mismatched-list-crash.html
Comment 9 Build Bot 2013-06-19 21:43:15 PDT
Created attachment 205054 [details]
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-14  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.3
Comment 10 Alexis Menard (darktears) 2013-06-20 12:17:07 PDT
Created attachment 205110 [details]
Patch
Comment 11 Alexis Menard (darktears) 2013-06-21 15:17:33 PDT
Created attachment 205220 [details]
Patch
Comment 12 Andreas Kling 2013-07-05 04:59:53 PDT
Comment on attachment 205220 [details]
Patch

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

r=me.

I think this patch is an interesting step in the right direction. I'm sure we can refine it more over time.

> Source/WebCore/ChangeLog:6
> +        Today CSSProperty holds its metadata in the following way :

I feel like this ChangeLog would be a lot more digestible if you simply made an "ASCII art" diagram of the new memory layout.

> Source/WebCore/css/StylePropertyShorthand.cpp:627
> +const Vector<const StylePropertyShorthand*> matchingShorthandsForLonghand(CSSPropertyID propertyID)

Can we make this return a reference instead of a Vector by value?

> Source/WebCore/css/StylePropertyShorthand.h:60
> +    CSSPropertyID id() const { return m_shorthandID; }

I'd call this shorthandID() rather than id().

> Source/WebCore/css/makeprop.pl:35
> +die "We've reached more than 1024 CSS properties, please make sure to update CSSProperty/StylePropertyMetadata accordingly" if (scalar(@NAMES) > 1024);

Great idea putting this here.
Comment 13 Alexis Menard (darktears) 2013-07-05 05:11:14 PDT
(In reply to comment #12)
> (From update of attachment 205220 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=205220&action=review
> 
> r=me.
> 
> I think this patch is an interesting step in the right direction. I'm sure we can refine it more over time.
> 
> > Source/WebCore/ChangeLog:6
> > +        Today CSSProperty holds its metadata in the following way :
> 
> I feel like this ChangeLog would be a lot more digestible if you simply made an "ASCII art" diagram of the new memory layout.

Ahahaha I can try to do that.

> 
> > Source/WebCore/css/StylePropertyShorthand.cpp:627
> > +const Vector<const StylePropertyShorthand*> matchingShorthandsForLonghand(CSSPropertyID propertyID)
> 
> Can we make this return a reference instead of a Vector by value?

Well if I do that then :

return map.get(propertyID); return a ref to a temporary variable.

typedef HashMap<CSSPropertyID, Vector<StylePropertyShorthand*> > longhandsMap;

could be changed maybe but not sure if it would be cleaner. Thoughts?

> 
> > Source/WebCore/css/StylePropertyShorthand.h:60
> > +    CSSPropertyID id() const { return m_shorthandID; }
> 
> I'd call this shorthandID() rather than id().

Will change.

> 
> > Source/WebCore/css/makeprop.pl:35
> > +die "We've reached more than 1024 CSS properties, please make sure to update CSSProperty/StylePropertyMetadata accordingly" if (scalar(@NAMES) > 1024);
> 
> Great idea putting this here.

:D I saw it coming hitting the future me working there.
Comment 14 Ryosuke Niwa 2013-07-14 17:41:42 PDT
It seems like the blink patch got rolled out due to a regression?
Comment 15 Alexis Menard (darktears) 2013-07-15 03:59:19 PDT
*** Bug 118013 has been marked as a duplicate of this bug. ***
Comment 16 Alexis Menard (darktears) 2013-07-15 05:00:11 PDT
(In reply to comment #14)
> It seems like the blink patch got rolled out due to a regression?

The part that was rolled out was only the packing to uint16_t in StylePropertyMetada. The rest is there and is going to stay. In Blink I landed it in two parts.

It's a regression on Windows only where MSVC doesn't generate good code to access to the new 16 bits StylePropertyMetada. Clang and GCC are unaffected. I was busy the past weeks with internal stuff but I'm planning to see what I can do about Windows.
Comment 17 Alexis Menard (darktears) 2013-07-31 10:54:33 PDT
Created attachment 207863 [details]
Patch
Comment 18 Andreas Kling 2013-07-31 18:57:31 PDT
Comment on attachment 207863 [details]
Patch

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

This patch needs a "Reviewed by" line.

> Source/WebCore/ChangeLog:10
> +        ------------------------------------------------------------------------------------------
> +        | m_propertyID : 14 | m_shorthandID : 14 | m_important : 1| m_implicit : 1| m_inherited:1|
> +        ------------------------------------------------------------------------------------------

Seems like these boxes would look better if vertical. :)

> Source/WebCore/ChangeLog:39
> +        ------------------------------------------------------------------------------------------------------
> +        | m_propertyID : 10 (up to 1024 properties)| m_isSetFromShorthand : 1 | m_indexInShorthandsVector : 2|...
> +        ------------------------------------------------------------------------------------------------------

^
Comment 19 Alexis Menard (darktears) 2013-08-01 04:39:47 PDT
Created attachment 207911 [details]
Patch for landing
Comment 20 WebKit Commit Bot 2013-08-01 05:25:34 PDT
Comment on attachment 207911 [details]
Patch for landing

Clearing flags on attachment: 207911

Committed r153581: <http://trac.webkit.org/changeset/153581>
Comment 21 WebKit Commit Bot 2013-08-01 05:25:38 PDT
All reviewed patches have been landed.  Closing bug.