Changeset 140079 in webkit


Ignore:
Timestamp:
Jan 17, 2013 6:00:52 PM (11 years ago)
Author:
abarth@webkit.org
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140075 r140079  
     12013-01-17  Adam Barth  <abarth@webkit.org>
     2
     3        BackgroundHTMLParser should go 18% faster on html-parser-srcdoc benchmark
     4        https://bugs.webkit.org/show_bug.cgi?id=107201
     5
     6        Reviewed by Tony Gentilcore.
     7
     8        Prior to this patch, we would tokenize all the input before delivering
     9        any tokens to the main thread. Effectively, that prevented the
     10        background parser from running in parallel with the main thread.
     11
     12        This patch causes us to send tokens to the main thread periodically.
     13        The constant in this patch is somewhat arbitrary. We'll need to tune it
     14        later with more realistic workloads.
     15
     16        This patch improves the performance of the html-parser-srcdoc benchmark
     17        by 18%. (This patch is based on Eric's work in
     18        https://github.com/tonygentilcore/webkit/commit/072331194520c7770b5e34baefbbbba948834971.)
     19
     20        * html/parser/BackgroundHTMLParser.cpp:
     21        (WebCore):
     22        (WebCore::BackgroundHTMLParser::pumpTokenizer):
     23        (WebCore::BackgroundHTMLParser::sendTokensToMainThread):
     24
    1252013-01-17  Matt Falkenhagen  <falken@chromium.org>
    226
  • trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp

    r140055 r140079  
    4747
    4848#endif
     49
     50// FIXME: Tune this constant based on a benchmark. The current value was choosen arbitrarily.
     51static const size_t pendingTokenLimit = 4000;
    4952
    5053typedef const void* ParserIdentifier;
     
    158161        m_tokenizer->setShouldAllowCDATA(m_inForeignContent);
    159162        m_token.clear();
    160     }
    161 
    162 #ifndef NDEBUG
    163     checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens);
    164 #endif
     163
     164        if (m_pendingTokens.size() >= pendingTokenLimit)
     165            sendTokensToMainThread();
     166    }
    165167
    166168    sendTokensToMainThread();
     
    200202void BackgroundHTMLParser::sendTokensToMainThread()
    201203{
     204    if (m_pendingTokens.isEmpty()) {
     205        ASSERT(!m_isPausedWaitingForScripts);
     206        return;
     207    }
     208
     209#ifndef NDEBUG
     210    checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens);
     211#endif
     212
    202213    TokenDelivery* delivery = new TokenDelivery;
    203214    delivery->identifier = m_parserIdentifer;
Note: See TracChangeset for help on using the changeset viewer.