WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
251697
EventListenerMap's m_entries vector wastes a lot of vector capacity
https://bugs.webkit.org/show_bug.cgi?id=251697
Summary
EventListenerMap's m_entries vector wastes a lot of vector capacity
Simon Fraser (smfr)
Reported
2023-02-03 10:03:10 PST
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*)
Attachments
Patch
(1.17 KB, patch)
2023-02-06 11:12 PST
,
Simon Fraser (smfr)
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2023-02-03 10:03:46 PST
<
rdar://problem/105010273
>
Chris Dumez
Comment 2
2023-02-03 10:04:58 PST
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.
Simon Fraser (smfr)
Comment 3
2023-02-03 20:30:23 PST
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
Simon Fraser (smfr)
Comment 4
2023-02-03 20:45:37 PST
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)
Simon Fraser (smfr)
Comment 5
2023-02-03 20:48:22 PST
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; };
Simon Fraser (smfr)
Comment 6
2023-02-06 11:12:46 PST
Created
attachment 464867
[details]
Patch
EWS
Comment 7
2023-02-06 12:33:45 PST
Commit message contains (OOPS!) and no reviewer found, blocking PR #None
Simon Fraser (smfr)
Comment 8
2023-02-06 14:13:14 PST
https://github.com/WebKit/WebKit/pull/9713
EWS
Comment 9
2023-02-06 15:33:47 PST
Committed
259920@main
(ad21476ae97e): <
https://commits.webkit.org/259920@main
> Reviewed commits have been landed. Closing PR #9713 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug