Changeset 83940 in webkit


Ignore:
Timestamp:
Apr 14, 2011 8:48:42 PM (13 years ago)
Author:
eric@webkit.org
Message:

2011-04-14 Eric Seidel <eric@webkit.org>

Reviewed by Simon Fraser.

PumpSession should not call currentTime() in the constructor
https://bugs.webkit.org/show_bug.cgi?id=55211

currentTime() is expensive. So we avoid calling it in the constructor
and instead set startTime on the first check for a yield
(which in the synchronous case never happens, and in the yielding
case will happen immediately after the first token due to
processedTokens being set to INT_MAX).

This ended up being a large win on (my local copy of)
peacekeeper's domDynamicCreationCreateElement:

Before:
avg 366.3333333333333
median 366
stdev 2.712112747574399
min 362
max 377

After:
avg 345.96666666666664
median 346
stdev 1.6829207415152454
min 343
max 349

  • html/parser/HTMLDocumentParser.cpp:
  • html/parser/HTMLParserScheduler.h: (WebCore::PumpSession::PumpSession): (WebCore::HTMLParserScheduler::checkForYieldBeforeToken):
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83939 r83940  
     12011-04-14  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        PumpSession should not call currentTime() in the constructor
     6        https://bugs.webkit.org/show_bug.cgi?id=55211
     7
     8        currentTime() is expensive.  So we avoid calling it in the constructor
     9        and instead set startTime on the first check for a yield
     10        (which in the synchronous case never happens, and in the yielding
     11        case will happen immediately after the first token due to
     12        processedTokens being set to INT_MAX).
     13
     14        This ended up being a large win on (my local copy of)
     15        peacekeeper's domDynamicCreationCreateElement:
     16
     17        Before:
     18        avg 366.3333333333333
     19        median 366
     20        stdev 2.712112747574399
     21        min 362
     22        max 377
     23
     24        After:
     25        avg 345.96666666666664
     26        median 346
     27        stdev 1.6829207415152454
     28        min 343
     29        max 349
     30
     31        * html/parser/HTMLDocumentParser.cpp:
     32        * html/parser/HTMLParserScheduler.h:
     33        (WebCore::PumpSession::PumpSession):
     34        (WebCore::HTMLParserScheduler::checkForYieldBeforeToken):
     35
    1362011-04-14  Ami Fischman  <fischman@google.com>
    237
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r83456 r83940  
    4141#include "NestingLevelIncrementer.h"
    4242#include "Settings.h"
    43 #include <wtf/CurrentTime.h>
    4443
    4544namespace WebCore {
  • trunk/Source/WebCore/html/parser/HTMLParserScheduler.h

    r80861 r83940  
    2727#define HTMLParserScheduler_h
    2828
     29#include <limits.h>
     30
    2931#include "NestingLevelIncrementer.h"
    3032#include "Timer.h"
     
    4042    PumpSession(unsigned& nestingLevel)
    4143        : NestingLevelIncrementer(nestingLevel)
    42         , processedTokens(0)
    43         , startTime(currentTime())
     44        // Setting processedTokens to INT_MAX causes us to check for yields
     45        // after any token during any parse where yielding is allowed.
     46        // At that time we'll initialize startTime.
     47        , processedTokens(INT_MAX)
     48        , startTime(0)
    4449        , needsYield(false)
    4550    {
     
    6469    {
    6570        if (session.processedTokens > m_parserChunkSize) {
     71            // currentTime() can be expensive.  By delaying, we avoided calling
     72            // currentTime() when constructing non-yielding PumpSessions.
     73            if (!session.startTime)
     74                session.startTime = currentTime();
     75
    6676            session.processedTokens = 0;
    6777            double elapsedTime = currentTime() - session.startTime;
Note: See TracChangeset for help on using the changeset viewer.