Changeset 266689 in webkit
- Timestamp:
- Sep 6, 2020, 5:59:52 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
style/PropertyCascade.cpp (modified) (4 diffs)
-
style/PropertyCascade.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r266688 r266689 1 2020-09-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [MotionMark - Multiply] Web process spends ~1% of total samples in PropertyCascade::resolveDirectionAndWritingMode 4 https://bugs.webkit.org/show_bug.cgi?id=216223 5 6 Reviewed by Darin Adler. 7 8 A few subtests in MotionMark (Leaves, Focus, Design, and especially Multiply) spend large amounts of time in 9 style resolution (`Document::resolveStyle`) due to constant style changes across many elements during every 10 frame. In Multiply, ~3-4% of the time underneath `Document::resolveStyle` is spent resolving direction and 11 writing modes inside `PropertyCascade::resolveDirectionAndWritingMode` (i.e., ~2.3 million invocations). This 12 helper function is responsible for computing the text direction and CSS writing mode that is used to resolve 13 direction-aware CSS properties (which are enumerated in `CSSProperty::isDirectionAwareProperty`). Resolving the 14 direction and writing mode involves iterating over all of the matched CSS properties (`m_matchResult`) in the 15 property cascade in search of CSS properties for writing and direction, which can be relatively expensive when 16 there are lots of properties in the cascade. 17 18 However, if there are no direction-aware CSS properties in the cascade, this work can actually be elided; to 19 achieve this, we can store the inherited `Direction` in `m_direction`, and then lazily resolve it if needed. 20 21 I measured this locally to yield a little under ~1% in the Multiply subtest in MotionMark. Otherwise, there is 22 no change in behavior; see below for more details. 23 24 * style/PropertyCascade.cpp: 25 (WebCore::Style::PropertyCascade::PropertyCascade): 26 (WebCore::Style::PropertyCascade::set): 27 28 If we encounter a direction-aware CSS property, then use `direction()` to ensure that the direction and writing 29 mode are resolved. 30 31 (WebCore::Style::PropertyCascade::direction const): 32 33 Make this getter call `resolveDirectionAndWritingMode` if needed. 34 35 * style/PropertyCascade.h: 36 37 Add a new `bool` member to keep track of whether or not the CSS direction has not yet been resolved. Note that 38 since this member variable fits within the padding after `Direction m_direction;`, this class is still the same 39 size. 40 41 (WebCore::Style::PropertyCascade::direction const): Deleted. 42 1 43 2020-09-06 Myles C. Maxfield <mmaxfield@apple.com> 2 44 -
trunk/Source/WebCore/style/PropertyCascade.cpp
r262922 r266689 149 149 : m_matchResult(matchResult) 150 150 , m_includedProperties(includedProperties) 151 , m_direction( resolveDirectionAndWritingMode(direction))151 , m_direction(direction) 152 152 { 153 153 buildCascade(cascadeLevels); … … 157 157 : m_matchResult(parent.m_matchResult) 158 158 , m_includedProperties(parent.m_includedProperties) 159 , m_direction(parent.m_direction) 159 , m_direction(parent.direction()) 160 , m_directionIsUnresolved(false) 160 161 { 161 162 buildCascade(cascadeLevels); … … 197 198 void PropertyCascade::set(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel, ScopeOrdinal styleScopeOrdinal) 198 199 { 199 if (CSSProperty::isDirectionAwareProperty(id)) 200 id = CSSProperty::resolveDirectionAwareProperty(id, m_direction.textDirection, m_direction.writingMode); 200 if (CSSProperty::isDirectionAwareProperty(id)) { 201 auto direction = this->direction(); 202 id = CSSProperty::resolveDirectionAwareProperty(id, direction.textDirection, direction.writingMode); 203 } 201 204 202 205 ASSERT(!shouldApplyPropertyInParseOrder(id)); … … 405 408 } 406 409 407 } 408 } 410 PropertyCascade::Direction PropertyCascade::direction() const 411 { 412 if (m_directionIsUnresolved) { 413 m_direction = resolveDirectionAndWritingMode(m_direction); 414 m_directionIsUnresolved = false; 415 } 416 return m_direction; 417 } 418 419 } 420 } -
trunk/Source/WebCore/style/PropertyCascade.h
r252313 r266689 68 68 const HashMap<AtomString, Property>& customProperties() const { return m_customProperties; } 69 69 70 Direction direction() const { return m_direction; }70 Direction direction() const; 71 71 72 72 const PropertyCascade* propertyCascadeForRollback(CascadeLevel) const; … … 86 86 const MatchResult& m_matchResult; 87 87 const IncludedProperties m_includedProperties; 88 const Direction m_direction; 88 mutable Direction m_direction; 89 mutable bool m_directionIsUnresolved { true }; 89 90 90 91 Property m_properties[numCSSProperties + 2];
Note:
See TracChangeset
for help on using the changeset viewer.