Changeset 267582 in webkit
- Timestamp:
- Sep 25, 2020, 11:20:55 AM (6 years ago)
- Location:
- branches/safari-610-branch/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
-
branches/safari-610-branch/Source/WebCore/ChangeLog
r267581 r267582 1 2020-09-22 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r266689. rdar://problem/69382883 4 5 [MotionMark - Multiply] Web process spends ~1% of total samples in PropertyCascade::resolveDirectionAndWritingMode 6 https://bugs.webkit.org/show_bug.cgi?id=216223 7 8 Reviewed by Darin Adler. 9 10 A few subtests in MotionMark (Leaves, Focus, Design, and especially Multiply) spend large amounts of time in 11 style resolution (`Document::resolveStyle`) due to constant style changes across many elements during every 12 frame. In Multiply, ~3-4% of the time underneath `Document::resolveStyle` is spent resolving direction and 13 writing modes inside `PropertyCascade::resolveDirectionAndWritingMode` (i.e., ~2.3 million invocations). This 14 helper function is responsible for computing the text direction and CSS writing mode that is used to resolve 15 direction-aware CSS properties (which are enumerated in `CSSProperty::isDirectionAwareProperty`). Resolving the 16 direction and writing mode involves iterating over all of the matched CSS properties (`m_matchResult`) in the 17 property cascade in search of CSS properties for writing and direction, which can be relatively expensive when 18 there are lots of properties in the cascade. 19 20 However, if there are no direction-aware CSS properties in the cascade, this work can actually be elided; to 21 achieve this, we can store the inherited `Direction` in `m_direction`, and then lazily resolve it if needed. 22 23 I measured this locally to yield a little under ~1% in the Multiply subtest in MotionMark. Otherwise, there is 24 no change in behavior; see below for more details. 25 26 * style/PropertyCascade.cpp: 27 (WebCore::Style::PropertyCascade::PropertyCascade): 28 (WebCore::Style::PropertyCascade::set): 29 30 If we encounter a direction-aware CSS property, then use `direction()` to ensure that the direction and writing 31 mode are resolved. 32 33 (WebCore::Style::PropertyCascade::direction const): 34 35 Make this getter call `resolveDirectionAndWritingMode` if needed. 36 37 * style/PropertyCascade.h: 38 39 Add a new `bool` member to keep track of whether or not the CSS direction has not yet been resolved. Note that 40 since this member variable fits within the padding after `Direction m_direction;`, this class is still the same 41 size. 42 43 (WebCore::Style::PropertyCascade::direction const): Deleted. 44 45 46 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266689 268f45cc-cd09-0410-ab3c-d52691b4dbfc 47 48 2020-09-06 Wenson Hsieh <wenson_hsieh@apple.com> 49 50 [MotionMark - Multiply] Web process spends ~1% of total samples in PropertyCascade::resolveDirectionAndWritingMode 51 https://bugs.webkit.org/show_bug.cgi?id=216223 52 53 Reviewed by Darin Adler. 54 55 A few subtests in MotionMark (Leaves, Focus, Design, and especially Multiply) spend large amounts of time in 56 style resolution (`Document::resolveStyle`) due to constant style changes across many elements during every 57 frame. In Multiply, ~3-4% of the time underneath `Document::resolveStyle` is spent resolving direction and 58 writing modes inside `PropertyCascade::resolveDirectionAndWritingMode` (i.e., ~2.3 million invocations). This 59 helper function is responsible for computing the text direction and CSS writing mode that is used to resolve 60 direction-aware CSS properties (which are enumerated in `CSSProperty::isDirectionAwareProperty`). Resolving the 61 direction and writing mode involves iterating over all of the matched CSS properties (`m_matchResult`) in the 62 property cascade in search of CSS properties for writing and direction, which can be relatively expensive when 63 there are lots of properties in the cascade. 64 65 However, if there are no direction-aware CSS properties in the cascade, this work can actually be elided; to 66 achieve this, we can store the inherited `Direction` in `m_direction`, and then lazily resolve it if needed. 67 68 I measured this locally to yield a little under ~1% in the Multiply subtest in MotionMark. Otherwise, there is 69 no change in behavior; see below for more details. 70 71 * style/PropertyCascade.cpp: 72 (WebCore::Style::PropertyCascade::PropertyCascade): 73 (WebCore::Style::PropertyCascade::set): 74 75 If we encounter a direction-aware CSS property, then use `direction()` to ensure that the direction and writing 76 mode are resolved. 77 78 (WebCore::Style::PropertyCascade::direction const): 79 80 Make this getter call `resolveDirectionAndWritingMode` if needed. 81 82 * style/PropertyCascade.h: 83 84 Add a new `bool` member to keep track of whether or not the CSS direction has not yet been resolved. Note that 85 since this member variable fits within the padding after `Direction m_direction;`, this class is still the same 86 size. 87 88 (WebCore::Style::PropertyCascade::direction const): Deleted. 89 1 90 2020-09-22 Alan Coon <alancoon@apple.com> 2 91 -
branches/safari-610-branch/Source/WebCore/style/PropertyCascade.cpp
r262922 r267582 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 } -
branches/safari-610-branch/Source/WebCore/style/PropertyCascade.h
r252313 r267582 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.