Using the patch in bug 186698, and testing on a wikipedia page, we see that EventListenerMap::m_entries is the second-most wasteful site for vector capacity: Wasted capacity: 65640 bytes (used 6680 of 72320 bytes, utilization: 9.24%) - 1923 allocations 1 0x2fc39b217 WebCore::EventListenerMap::EventListenerMap() 2 0x2fcd93008 WebCore::RenderObject::RenderObject(WebCore::Node&) 3 0x2fcceef18 WebCore::RenderElement::RenderElement(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) 4 0x2fcd69351 WebCore::RenderLayerModelObject::RenderLayerModelObject(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) 5 0x2fccbe2b1 WebCore::RenderBoxModelObject::RenderBoxModelObject(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) 6 0x2fcd287b3 WebCore::RenderInline::RenderInline(WebCore::Element&, WebCore::RenderStyle&&) Wasted capacity: 7960 bytes (used 1000 of 8960 bytes, utilization: 11.16%) - 278 allocations 1 0x2fc39b217 WebCore::EventListenerMap::EventListenerMap() 2 0x2fcd93008 WebCore::RenderObject::RenderObject(WebCore::Node&) 3 0x2fcceef18 WebCore::RenderElement::RenderElement(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) 4 0x2fcd69351 WebCore::RenderLayerModelObject::RenderLayerModelObject(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) 5 0x2fccbe261 WebCore::RenderBox::RenderBox(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) Wasted capacity: 3400 bytes (used 440 of 3840 bytes, utilization: 11.46%) - 7 allocations 1 0x2fc39b217 WebCore::EventListenerMap::EventListenerMap() 2 0x2fc5e7fb0 WebCore::CheckboxInputType::CheckboxInputType(WebCore::HTMLInputElement&) 3 0x2fc5e73e8 WTF::Ref<WebCore::InputType, WTF::RawPtrTraits<WebCore::InputType> > WebCore::createInputType<WebCore::CheckboxInputType>(WebCore::HTMLInputElement&) 4 0x2fc5e0772 WebCore::InputType::createIfDifferent(WebCore::HTMLInputElement&, WTF::AtomString const&, WebCore::InputType*)
<rdar://problem/105010273>
This is hot code and this vector was tweaked recently for speedometer gains. If we make changes, we should run speedometer to make sure we don't regress.
I ran Speedometer with some instrumentation. The max number of entries in the vector is 25, and the mean is 1.63. Here's a table of size frequencies (excluding zeros): Size Instance count 1 25751 2 3388 6 2010 3 2010 4 1020 5 50 25 20 9 18 17 8
Going to perf-test a patch that gets this down to: Wasted capacity: 11400 bytes (used 6680 of 18080 bytes, utilization: 36.95%) - 1959 allocations 1 0x3343c9df7 WebCore::EventListenerMap::EventListenerMap() 2 0x334dc5218 WebCore::RenderObject::RenderObject(WebCore::Node&) 3 0x334d20f58 WebCore::RenderElement::RenderElement(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) 4 0x334d9b561 WebCore::RenderLayerModelObject::RenderLayerModelObject(WebCore::Element&, WebCore::RenderStyle&&, unsigned int) 5 0x334cf0281 WebCore::RenderBoxModelObject::RenderBoxModelObject(WebCore::Element&, WebCore::RenderStyle&&, unsigned int)
diff --git a/Source/WebCore/dom/EventListenerMap.h b/Source/WebCore/dom/EventListenerMap.h index 25a4340b6014f9e2bd2f1cd1b19760c86c30a6d7..55e619529189ad8bf80753514035d50be115c49c 100644 --- a/Source/WebCore/dom/EventListenerMap.h +++ b/Source/WebCore/dom/EventListenerMap.h @@ -74,7 +74,7 @@ public: Lock& lock() { return m_lock; } private: - Vector<std::pair<AtomString, EventListenerVector>> m_entries; + Vector<std::pair<AtomString, EventListenerVector>, 0, CrashOnOverflow, 4> m_entries; Lock m_lock; };
Created attachment 464867 [details] Patch
Commit message contains (OOPS!) and no reviewer found, blocking PR #None
https://github.com/WebKit/WebKit/pull/9713
Committed 259920@main (ad21476ae97e): <https://commits.webkit.org/259920@main> Reviewed commits have been landed. Closing PR #9713 and removing active labels.