Changeset 236241 in webkit
- Timestamp:
- Sep 19, 2018, 11:14:59 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
dom/Element.cpp (modified) (1 diff)
-
dom/Element.h (modified) (1 diff)
-
dom/ElementRareData.h (modified) (3 diffs)
-
dom/Node.cpp (modified) (5 diffs)
-
dom/NodeRareData.cpp (modified) (1 diff)
-
dom/NodeRareData.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r236228 r236241 1 2018-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 Improve node statistics for rare data 4 https://bugs.webkit.org/show_bug.cgi?id=189775 5 6 Reviewed by Simon Fraser. 7 8 Report reasons we created NodeRareData and ElementRareData in node statistics. 9 10 Added NodeRareData::useTypes and ElementRareData::useTypes which returns OptionSet<NodeRareData::UseType> 11 indicating which instance member of the rare data is currently in use. 12 13 * dom/Element.cpp: 14 * dom/Element.h: 15 * dom/ElementRareData.h: 16 (WebCore::defaultMinimumSizeForResizing): 17 (WebCore::ElementRareData::useTypes const): 18 * dom/Node.cpp: 19 (WebCore::stringForRareDataUseType): 20 (WebCore::Node::dumpStatistics): 21 * dom/NodeRareData.cpp: 22 * dom/NodeRareData.h: 23 (WebCore::NodeRareData::useTypes const): 24 1 25 2018-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 26 -
trunk/Source/WebCore/dom/Element.cpp
r235830 r236241 3443 3443 #endif 3444 3444 3445 #if defDUMP_NODE_STATISTICS3445 #if DUMP_NODE_STATISTICS 3446 3446 bool Element::hasNamedNodeMap() const 3447 3447 { -
trunk/Source/WebCore/dom/Element.h
r235806 r236241 105 105 #endif 106 106 107 #if defDUMP_NODE_STATISTICS107 #if DUMP_NODE_STATISTICS 108 108 bool hasNamedNodeMap() const; 109 109 #endif -
trunk/Source/WebCore/dom/ElementRareData.h
r234884 r236241 33 33 34 34 namespace WebCore { 35 36 inline IntSize defaultMinimumSizeForResizing() 37 { 38 return IntSize(LayoutUnit::max(), LayoutUnit::max()); 39 } 35 40 36 41 class ElementRareData : public NodeRareData { … … 121 126 IntersectionObserverData* intersectionObserverData() { return m_intersectionObserverData.get(); } 122 127 void setIntersectionObserverData(std::unique_ptr<IntersectionObserverData>&& data) { m_intersectionObserverData = WTFMove(data); } 128 #endif 129 130 #if DUMP_NODE_STATISTICS 131 OptionSet<UseType> useTypes() const 132 { 133 auto result = NodeRareData::useTypes(); 134 if (m_tabIndexWasSetExplicitly) 135 result.add(UseType::TabIndex); 136 if (m_styleAffectedByActive || m_styleAffectedByEmpty || m_styleAffectedByFocusWithin || m_childrenAffectedByHover 137 || m_childrenAffectedByDrag || m_childrenAffectedByLastChildRules || m_childrenAffectedByForwardPositionalRules 138 || m_descendantsAffectedByForwardPositionalRules || m_childrenAffectedByBackwardPositionalRules 139 || m_descendantsAffectedByBackwardPositionalRules || m_childrenAffectedByPropertyBasedBackwardPositionalRules) 140 result.add(UseType::StyleFlags); 141 if (m_minimumSizeForResizing != defaultMinimumSizeForResizing()) 142 result.add(UseType::MinimumSize); 143 if (!m_savedLayerScrollPosition.isZero()) 144 result.add(UseType::ScrollingPosition); 145 if (m_computedStyle) 146 result.add(UseType::ComputedStyle); 147 if (m_dataset) 148 result.add(UseType::Dataset); 149 if (m_classList) 150 result.add(UseType::ClassList); 151 if (m_shadowRoot) 152 result.add(UseType::ShadowRoot); 153 if (m_customElementReactionQueue) 154 result.add(UseType::CustomElementQueue); 155 if (m_attributeMap) 156 result.add(UseType::AttributeMap); 157 if (m_intersectionObserverData) 158 result.add(UseType::InteractionObserver); 159 if (m_beforePseudoElement || m_afterPseudoElement) 160 result.add(UseType::PseudoElements); 161 return result; 162 } 123 163 #endif 124 164 … … 166 206 }; 167 207 168 inline IntSize defaultMinimumSizeForResizing()169 {170 return IntSize(LayoutUnit::max(), LayoutUnit::max());171 }172 173 208 inline ElementRareData::ElementRareData(RenderElement* renderer) 174 209 : NodeRareData(renderer) -
trunk/Source/WebCore/dom/Node.cpp
r236002 r236241 92 92 return liveNodes; 93 93 } 94 95 static const char* stringForRareDataUseType(NodeRareData::UseType useType) 96 { 97 switch (useType) { 98 case NodeRareData::UseType::ConnectedFrameCount: 99 return "ConnectedFrameCount"; 100 case NodeRareData::UseType::NodeList: 101 return "NodeList"; 102 case NodeRareData::UseType::MutationObserver: 103 return "MutationObserver"; 104 case NodeRareData::UseType::TabIndex: 105 return "TabIndex"; 106 case NodeRareData::UseType::StyleFlags: 107 return "StyleFlags"; 108 case NodeRareData::UseType::MinimumSize: 109 return "MinimumSize"; 110 case NodeRareData::UseType::ScrollingPosition: 111 return "ScrollingPosition"; 112 case NodeRareData::UseType::ComputedStyle: 113 return "ComputedStyle"; 114 case NodeRareData::UseType::Dataset: 115 return "Dataset"; 116 case NodeRareData::UseType::ClassList: 117 return "ClassList"; 118 case NodeRareData::UseType::ShadowRoot: 119 return "ShadowRoot"; 120 case NodeRareData::UseType::CustomElementQueue: 121 return "CustomElementQueue"; 122 case NodeRareData::UseType::AttributeMap: 123 return "AttributeMap"; 124 case NodeRareData::UseType::InteractionObserver: 125 return "InteractionObserver"; 126 case NodeRareData::UseType::PseudoElements: 127 return "PseudoElements"; 128 } 129 return nullptr; 130 } 131 94 132 #endif 95 133 … … 118 156 size_t elementsWithNamedNodeMap = 0; 119 157 158 HashMap<uint16_t, size_t> rareDataSingleUseTypeCounts; 159 size_t mixedRareDataUseCount = 0; 160 120 161 for (auto* node : liveNodeSet()) { 121 162 if (node->hasRareData()) { … … 126 167 ++elementsWithNamedNodeMap; 127 168 } 169 auto* rareData = node->rareData(); 170 auto useTypes = is<Element>(node) ? static_cast<ElementRareData*>(rareData)->useTypes() : rareData->useTypes(); 171 unsigned useTypeCount = 0; 172 for (auto type : useTypes) { 173 UNUSED_PARAM(type); 174 useTypeCount++; 175 } 176 if (useTypeCount == 1) { 177 auto result = rareDataSingleUseTypeCounts.add(static_cast<uint16_t>(*useTypes.begin()), 0); 178 result.iterator->value++; 179 } else 180 mixedRareDataUseCount++; 128 181 } 129 182 … … 144 197 for (unsigned i = 0; i < length; ++i) { 145 198 const Attribute& attr = elementData->attributeAt(i); 146 if ( !attr.isEmpty())199 if (element.attrIfExists(attr.name())) 147 200 ++attributesWithAttr; 148 201 } … … 189 242 190 243 printf("Number of Nodes: %d\n\n", liveNodeSet().size()); 191 printf("Number of Nodes with RareData: %zu\n\n", nodesWithRareData); 244 printf("Number of Nodes with RareData: %zu\n", nodesWithRareData); 245 printf(" Mixed use: %zu\n", mixedRareDataUseCount); 246 for (auto it : rareDataSingleUseTypeCounts) 247 printf(" %s: %zu\n", stringForRareDataUseType(static_cast<NodeRareData::UseType>(it.key)), it.value); 248 printf("\n"); 249 192 250 193 251 printf("NodeType distribution:\n"); -
trunk/Source/WebCore/dom/NodeRareData.cpp
r153772 r236241 41 41 COMPILE_ASSERT(sizeof(NodeRareData) == sizeof(SameSizeAsNodeRareData), NodeRareDataShouldStaySmall); 42 42 43 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow 44 static_assert(Page::maxNumberOfFrames < 1024, "Frame limit should fit in rare data count"); 45 43 46 } // namespace WebCore -
trunk/Source/WebCore/dom/NodeRareData.h
r219237 r236241 27 27 #include "LiveNodeList.h" 28 28 #include "MutationObserverRegistration.h" 29 #include "Page.h"30 29 #include "QualifiedName.h" 31 30 #include "TagCollection.h" … … 251 250 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; 252 251 public: 252 #if defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS 253 enum class UseType : uint16_t { 254 ConnectedFrameCount = 1 << 0, 255 NodeList = 1 << 1, 256 MutationObserver = 1 << 2, 257 258 TabIndex = 1 << 3, 259 StyleFlags = 1 << 4, 260 MinimumSize = 1 << 5, 261 ScrollingPosition = 1 << 6, 262 ComputedStyle = 1 << 7, 263 Dataset = 1 << 8, 264 ClassList = 1 << 9, 265 ShadowRoot = 1 << 10, 266 CustomElementQueue = 1 << 11, 267 AttributeMap = 1 << 12, 268 InteractionObserver = 1 << 13, 269 PseudoElements = 1 << 14, 270 }; 271 #endif 272 253 273 NodeRareData(RenderObject* renderer) 254 274 : NodeRareDataBase(renderer) … … 284 304 m_connectedFrameCount -= amount; 285 305 } 306 307 #if DUMP_NODE_STATISTICS 308 OptionSet<UseType> useTypes() const 309 { 310 OptionSet<UseType> result; 311 if (m_connectedFrameCount) 312 result.add(UseType::ConnectedFrameCount); 313 if (m_nodeLists) 314 result.add(UseType::NodeList); 315 if (m_mutationObserverData) 316 result.add(UseType::MutationObserver); 317 return result; 318 } 319 #endif 286 320 287 321 private: … … 315 349 } 316 350 317 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow318 static_assert(Page::maxNumberOfFrames < 1024, "Frame limit should fit in rare data count");319 320 351 } // namespace WebCore
Note:
See TracChangeset
for help on using the changeset viewer.