Title: [292277] trunk/Source/WebCore
Revision
292277
Author
gga...@apple.com
Date
2022-04-03 18:14:05 -0700 (Sun, 03 Apr 2022)

Log Message

Document::addListenerTypeIfNeeded should not call pthread_get_specific 14 times
https://bugs.webkit.org/show_bug.cgi?id=238702

Reviewed by Cameron McCormack.

Document::addListenerTypeIfNeeded => pthread_get_specific showed up in
a profile of Preact-TodoMVC, and I verified by disassembly that the
generated code really does call pthread_get_specific 14x, along with
related inefficiencies.

Only worth about 0.5%, so I didn't A/B test it.

You could imagine lots of other ways to speed up this function /
functionality, but why don't we start with 14x and see where that takes
us.

* dom/Document.cpp:
(WebCore::Document::addListenerTypeIfNeeded): Use a local variable
because, like, come on.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292276 => 292277)


--- trunk/Source/WebCore/ChangeLog	2022-04-03 19:51:59 UTC (rev 292276)
+++ trunk/Source/WebCore/ChangeLog	2022-04-04 01:14:05 UTC (rev 292277)
@@ -1,3 +1,25 @@
+2022-04-03  Geoffrey Garen  <gga...@apple.com>
+
+        Document::addListenerTypeIfNeeded should not call pthread_get_specific 14 times
+        https://bugs.webkit.org/show_bug.cgi?id=238702
+
+        Reviewed by Cameron McCormack.
+
+        Document::addListenerTypeIfNeeded => pthread_get_specific showed up in
+        a profile of Preact-TodoMVC, and I verified by disassembly that the
+        generated code really does call pthread_get_specific 14x, along with
+        related inefficiencies.
+
+        Only worth about 0.5%, so I didn't A/B test it.
+
+        You could imagine lots of other ways to speed up this function / 
+        functionality, but why don't we start with 14x and see where that takes
+        us.
+
+        * dom/Document.cpp:
+        (WebCore::Document::addListenerTypeIfNeeded): Use a local variable
+        because, like, come on.
+
 2022-04-03  Tyler Wilcock  <tyle...@apple.com>
 
         -[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:] should fail fast if the given parameter wrapper has no backing object

Modified: trunk/Source/WebCore/dom/Document.cpp (292276 => 292277)


--- trunk/Source/WebCore/dom/Document.cpp	2022-04-03 19:51:59 UTC (rev 292276)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-04-04 01:14:05 UTC (rev 292277)
@@ -5276,33 +5276,34 @@
 
 void Document::addListenerTypeIfNeeded(const AtomString& eventType)
 {
-    if (eventType == eventNames().DOMSubtreeModifiedEvent)
+    auto& eventNames = WebCore::eventNames();
+    if (eventType == eventNames.DOMSubtreeModifiedEvent)
         addListenerType(DOMSUBTREEMODIFIED_LISTENER);
-    else if (eventType == eventNames().DOMNodeInsertedEvent)
+    else if (eventType == eventNames.DOMNodeInsertedEvent)
         addListenerType(DOMNODEINSERTED_LISTENER);
-    else if (eventType == eventNames().DOMNodeRemovedEvent)
+    else if (eventType == eventNames.DOMNodeRemovedEvent)
         addListenerType(DOMNODEREMOVED_LISTENER);
-    else if (eventType == eventNames().DOMNodeRemovedFromDocumentEvent)
+    else if (eventType == eventNames.DOMNodeRemovedFromDocumentEvent)
         addListenerType(DOMNODEREMOVEDFROMDOCUMENT_LISTENER);
-    else if (eventType == eventNames().DOMNodeInsertedIntoDocumentEvent)
+    else if (eventType == eventNames.DOMNodeInsertedIntoDocumentEvent)
         addListenerType(DOMNODEINSERTEDINTODOCUMENT_LISTENER);
-    else if (eventType == eventNames().DOMCharacterDataModifiedEvent)
+    else if (eventType == eventNames.DOMCharacterDataModifiedEvent)
         addListenerType(DOMCHARACTERDATAMODIFIED_LISTENER);
-    else if (eventType == eventNames().overflowchangedEvent)
+    else if (eventType == eventNames.overflowchangedEvent)
         addListenerType(OVERFLOWCHANGED_LISTENER);
-    else if (eventType == eventNames().scrollEvent)
+    else if (eventType == eventNames.scrollEvent)
         addListenerType(SCROLL_LISTENER);
-    else if (eventType == eventNames().webkitmouseforcewillbeginEvent)
+    else if (eventType == eventNames.webkitmouseforcewillbeginEvent)
         addListenerType(FORCEWILLBEGIN_LISTENER);
-    else if (eventType == eventNames().webkitmouseforcechangedEvent)
+    else if (eventType == eventNames.webkitmouseforcechangedEvent)
         addListenerType(FORCECHANGED_LISTENER);
-    else if (eventType == eventNames().webkitmouseforcedownEvent)
+    else if (eventType == eventNames.webkitmouseforcedownEvent)
         addListenerType(FORCEDOWN_LISTENER);
-    else if (eventType == eventNames().webkitmouseforceupEvent)
+    else if (eventType == eventNames.webkitmouseforceupEvent)
         addListenerType(FORCEUP_LISTENER);
-    else if (eventType == eventNames().focusinEvent)
+    else if (eventType == eventNames.focusinEvent)
         addListenerType(FOCUSIN_LISTENER);
-    else if (eventType == eventNames().focusoutEvent)
+    else if (eventType == eventNames.focusoutEvent)
         addListenerType(FOCUSOUT_LISTENER);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to