Title: [140079] trunk/Source/WebCore
Revision
140079
Author
aba...@webkit.org
Date
2013-01-17 18:00:52 -0800 (Thu, 17 Jan 2013)

Log Message

BackgroundHTMLParser should go 18% faster on html-parser-srcdoc benchmark
https://bugs.webkit.org/show_bug.cgi?id=107201

Reviewed by Tony Gentilcore.

Prior to this patch, we would tokenize all the input before delivering
any tokens to the main thread. Effectively, that prevented the
background parser from running in parallel with the main thread.

This patch causes us to send tokens to the main thread periodically.
The constant in this patch is somewhat arbitrary. We'll need to tune it
later with more realistic workloads.

This patch improves the performance of the html-parser-srcdoc benchmark
by 18%. (This patch is based on Eric's work in
https://github.com/tonygentilcore/webkit/commit/072331194520c7770b5e34baefbbbba948834971.)

* html/parser/BackgroundHTMLParser.cpp:
(WebCore):
(WebCore::BackgroundHTMLParser::pumpTokenizer):
(WebCore::BackgroundHTMLParser::sendTokensToMainThread):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (140078 => 140079)


--- trunk/Source/WebCore/ChangeLog	2013-01-18 01:58:12 UTC (rev 140078)
+++ trunk/Source/WebCore/ChangeLog	2013-01-18 02:00:52 UTC (rev 140079)
@@ -1,3 +1,27 @@
+2013-01-17  Adam Barth  <aba...@webkit.org>
+
+        BackgroundHTMLParser should go 18% faster on html-parser-srcdoc benchmark
+        https://bugs.webkit.org/show_bug.cgi?id=107201
+
+        Reviewed by Tony Gentilcore.
+
+        Prior to this patch, we would tokenize all the input before delivering
+        any tokens to the main thread. Effectively, that prevented the
+        background parser from running in parallel with the main thread.
+
+        This patch causes us to send tokens to the main thread periodically.
+        The constant in this patch is somewhat arbitrary. We'll need to tune it
+        later with more realistic workloads.
+
+        This patch improves the performance of the html-parser-srcdoc benchmark
+        by 18%. (This patch is based on Eric's work in
+        https://github.com/tonygentilcore/webkit/commit/072331194520c7770b5e34baefbbbba948834971.)
+
+        * html/parser/BackgroundHTMLParser.cpp:
+        (WebCore):
+        (WebCore::BackgroundHTMLParser::pumpTokenizer):
+        (WebCore::BackgroundHTMLParser::sendTokensToMainThread):
+
 2013-01-17  Matt Falkenhagen  <fal...@chromium.org>
 
         Top layer fails for inline elements

Modified: trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp (140078 => 140079)


--- trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp	2013-01-18 01:58:12 UTC (rev 140078)
+++ trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp	2013-01-18 02:00:52 UTC (rev 140079)
@@ -47,6 +47,9 @@
 
 #endif
 
+// FIXME: Tune this constant based on a benchmark. The current value was choosen arbitrarily.
+static const size_t pendingTokenLimit = 4000;
+
 typedef const void* ParserIdentifier;
 class HTMLDocumentParser;
 
@@ -157,12 +160,11 @@
         // FIXME: Need to set setForceNullCharacterReplacement based on m_inForeignContent as well.
         m_tokenizer->setShouldAllowCDATA(m_inForeignContent);
         m_token.clear();
+
+        if (m_pendingTokens.size() >= pendingTokenLimit)
+            sendTokensToMainThread();
     }
 
-#ifndef NDEBUG
-    checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens);
-#endif
-
     sendTokensToMainThread();
 }
 
@@ -199,6 +201,15 @@
 
 void BackgroundHTMLParser::sendTokensToMainThread()
 {
+    if (m_pendingTokens.isEmpty()) {
+        ASSERT(!m_isPausedWaitingForScripts);
+        return;
+    }
+
+#ifndef NDEBUG
+    checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens);
+#endif
+
     TokenDelivery* delivery = new TokenDelivery;
     delivery->identifier = m_parserIdentifer;
     delivery->tokens.swap(m_pendingTokens);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to