ASSIGNED 39181
Reduce the size of MutableStyleProperties
https://bugs.webkit.org/show_bug.cgi?id=39181
Summary Reduce the size of MutableStyleProperties
Simon Fraser (smfr)
Reported 2010-05-16 12:42:00 PDT
After the short membuster test, we have 15673 live CSSMutableStyleDeclarations at 128 bytes each for a total of 2,006,144 bytes. It would be good to shrink that.
Attachments
Simon Fraser (smfr)
Comment 1 2010-05-16 12:44:03 PDT
CSSMutableStyleDeclaration has this vector with inline size: Vector<CSSProperty, 4> m_properties; In the short membuster test, here is the frequency distribution of m_properties.size(): 0 47 1 424 2 92 3 45 4 27 5 15 6 11 7 4 8 15 9 23 10 14 11 16 12 15 13 17 14 14 15 7 16 8 17 4 18 10 19+ 42 so the majority of CSSMutableStyleDeclarations have just one property. Maybe we should reduce that inline size.
Simon Fraser (smfr)
Comment 2 2010-05-16 13:16:11 PDT
Results from 29-page membuster of reducing line vector capacity to 2: COUNT BYTES AVG CLASS_NAME TYPE BINARY ===== ===== === ========== ==== ====== before: 15673 2006144 128.0 WebCore::CSSMutableStyleDeclaration C++ WebCore after: 15556 1493376 96.0 WebCore::CSSMutableStyleDeclaration C++ WebCore
Simon Fraser (smfr)
Comment 3 2010-05-16 15:09:33 PDT
Here's the patch: diff --git a/WebCore/css/CSSMutableStyleDeclaration.cpp b/WebCore/css/CSSMutableStyleDeclaration.cpp index 44e0b17..7e8cb91 100644 --- a/WebCore/css/CSSMutableStyleDeclaration.cpp +++ b/WebCore/css/CSSMutableStyleDeclaration.cpp @@ -788,7 +788,7 @@ void CSSMutableStyleDeclaration::removePropertiesInSet(const int* set, unsigned for (unsigned i = 0; i < length; ++i) toRemove.add(set[i]); - Vector<CSSProperty, 4> newProperties; + Vector<CSSProperty, 2> newProperties; newProperties.reserveInitialCapacity(m_properties.size()); unsigned size = m_properties.size(); diff --git a/WebCore/css/CSSMutableStyleDeclaration.h b/WebCore/css/CSSMutableStyleDeclaration.h index f7759f4..9c64c0a 100644 --- a/WebCore/css/CSSMutableStyleDeclaration.h +++ b/WebCore/css/CSSMutableStyleDeclaration.h @@ -159,7 +159,7 @@ private: Vector<CSSProperty>::const_iterator findPropertyWithId(int propertyId) const; Vector<CSSProperty>::iterator findPropertyWithId(int propertyId); - Vector<CSSProperty, 4> m_properties; + Vector<CSSProperty, 2> m_properties; Node* m_node; unsigned m_variableDependentValueCount : 24;
Sam Weinig
Comment 4 2010-05-16 17:45:37 PDT
One thing Anders and I have been doing is also looking at the distributions for things like opening all of Safari's default bookmarks (eg, the News folder and Popular folder) as a sanity check. Membuster can be a little odd sometimes.
Simon Fraser (smfr)
Comment 5 2010-05-16 18:07:03 PDT
The inline capacity was originally added in http://trac.webkit.org/changeset/40554
Simon Fraser (smfr)
Comment 6 2018-12-01 11:49:35 PST
MutableStyleProperties is still 96 bytes: 15$ $ ./Tools/Scripts/dump-class-layout -c Release WebCore MutableStyleProperties +0 < 96> MutableStyleProperties +0 < 8> WebCore::StyleProperties WebCore::StyleProperties +0 < 8> WebCore::StylePropertiesBase WebCore::StylePropertiesBase +0 < 4> WTF::RefCounted<WebCore::StylePropertiesBase> WTF::RefCounted<WebCore::StylePropertiesBase> +0 < 4> WTF::RefCountedBase WTF::RefCountedBase +0 < 4> unsigned int m_refCount +4 < :3> unsigned int m_cssParserMode : 3 +4 < :2> unsigned int m_type : 2 +4 < :27> unsigned int m_arraySize : 27 +8 < 80> WTF::Vector<WebCore::CSSProperty, 4, WTF::CrashOnOverflow, 16> m_propertyVector +8 < 80> WTF::VectorBuffer<WebCore::CSSProperty, 4> WTF::VectorBuffer<WebCore::CSSProperty, 4> +8 < 16> WTF::VectorBufferBase<WebCore::CSSProperty> WTF::VectorBufferBase<WebCore::CSSProperty> +8 < 8> WebCore::CSSProperty * m_buffer +16 < 4> unsigned int m_capacity +20 < 4> unsigned int m_size +24 < 64> std::__1::aligned_storage<16, 8>::type [4] m_inlineBuffer +88 < 8> std::__1::unique_ptr<WebCore::PropertySetCSSStyleDeclaration, std::__1::default_delete<WebCore::PropertySetCSSStyleDeclaration> > m_cssomWrapper +88 < 8> std::__1::__compressed_pair<WebCore::PropertySetCSSStyleDeclaration *, std::__1::default_delete<WebCore::PropertySetCSSStyleDeclaration> > __ptr_ +88 < 8> std::__1::__compressed_pair_elem<WebCore::PropertySetCSSStyleDeclaration *, 0, false> std::__1::__compressed_pair_elem<WebCore::PropertySetCSSStyleDeclaration *, 0, false> +88 < 8> WebCore::PropertySetCSSStyleDeclaration * __value_ +88 < 1> std::__1::__compressed_pair_elem<std::__1::default_delete<WebCore::PropertySetCSSStyleDeclaration>, 1, true> std::__1::__compressed_pair_elem<std::__1::default_delete<WebCore::PropertySetCSSStyleDeclaration>, 1, true> +88 < 1> std::__1::default_delete<WebCore::PropertySetCSSStyleDeclaration> std::__1::default_delete<WebCore::PropertySetCSSStyleDeclaration> Total byte size: 96 Total pad bytes: 0
Note You need to log in before you can comment on or make changes to this bug.