Changeset 111109 in webkit


Ignore:
Timestamp:
Mar 16, 2012 7:32:51 PM (12 years ago)
Author:
haraken@chromium.org
Message:

[Chromium][Performance] Optimize innerText and outerText in Chromium/Mac
https://bugs.webkit.org/show_bug.cgi?id=81192

Reviewed by Dimitri Glazkov.

This patch makes innerText and outerText 4 times faster on Chromium/Mac.
A similar performance improvement will be also observed in APIs that are using
TextIterator::plainText() (e.g. Editting, SpellChecker, Clipboard, Pasteboard etc).

Performance test: https://bugs.webkit.org/attachment.cgi?id=131989

  • AppleWebKit/JavaScriptCore/Mac:

div.innerText : 2978.4ms
div.outerText : 2944.4ms

  • Chromium/V8/Mac without the patch:

div.innerText : 10050.8ms
div.outerText : 10072.2ms

  • Chromium/V8/Mac with the patch:

div.innerText: 2536.4ms
div.outerText: 2714ms

This patch just changes the initial buffer size of a plain text buffer on Chromium/Mac.
As shown below, in my local Chromium/Mac environment the performance changes
dramatically between 1<<15 and 1<<16, and in my local Chromium/Linux environment
the performance changes between 1<<17 and 1<<18. I am not yet sure what determines
these figures, but it seems there exists a performance gap at some point
depending on a malloc mechanism.

  • div.innerText results on Chromium/V8/Mac:

WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 14 ==> 2465.6 ms
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 15 ==> 2447.2 ms <--- after this patch
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 16 ==> 10250.8 ms <--- before this patch
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 17 ==> 10278.2 ms

  • div.innerText results on Chromium/V8/Linux:

WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 14 ==> 1569.8 ms
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 15 ==> 1531.8 ms
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 16 ==> 1543.2 ms <--- before/after this patch
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 17 ==> 1541.6 ms
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 18 ==> 12540.8 ms
WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 19 ==> 12340.8 ms

  • editing/TextIterator.cpp:

(WebCore::plainTextToMallocAllocatedBuffer):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r111108 r111109  
     12012-03-16  Kentaro Hara  <haraken@chromium.org>
     2
     3        [Chromium][Performance] Optimize innerText and outerText in Chromium/Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=81192
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        This patch makes innerText and outerText 4 times faster on Chromium/Mac.
     9        A similar performance improvement will be also observed in APIs that are using
     10        TextIterator::plainText() (e.g. Editting, SpellChecker, Clipboard, Pasteboard etc).
     11
     12        Performance test: https://bugs.webkit.org/attachment.cgi?id=131989
     13
     14        - AppleWebKit/JavaScriptCore/Mac:
     15        div.innerText : 2978.4ms
     16        div.outerText : 2944.4ms
     17
     18        - Chromium/V8/Mac without the patch:
     19        div.innerText : 10050.8ms
     20        div.outerText : 10072.2ms
     21
     22        - Chromium/V8/Mac with the patch:
     23        div.innerText: 2536.4ms
     24        div.outerText: 2714ms
     25
     26        This patch just changes the initial buffer size of a plain text buffer on Chromium/Mac.
     27        As shown below, in my local Chromium/Mac environment the performance changes
     28        dramatically between 1<<15 and 1<<16, and in my local Chromium/Linux environment
     29        the performance changes between 1<<17 and 1<<18. I am not yet sure what determines
     30        these figures, but it seems there exists a performance gap at some point
     31        depending on a malloc mechanism.
     32
     33        - div.innerText results on Chromium/V8/Mac:
     34        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 14 ==> 2465.6 ms
     35        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 15 ==> 2447.2 ms   <--- after this patch
     36        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 16 ==> 10250.8 ms  <--- before this patch
     37        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 17 ==> 10278.2 ms
     38
     39        - div.innerText results on Chromium/V8/Linux:
     40        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 14 ==> 1569.8 ms
     41        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 15 ==> 1531.8 ms
     42        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 16 ==> 1543.2 ms  <--- before/after this patch
     43        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 17 ==> 1541.6 ms
     44        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 18 ==> 12540.8 ms
     45        WTF_TEXT_ITERATOR_BUFFER_INITIAL_CAPACITY = 1 << 19 ==> 12340.8 ms
     46
     47        * editing/TextIterator.cpp:
     48        (WebCore::plainTextToMallocAllocatedBuffer):
     49
    1502012-03-16  Dmitry Titov  <dimich@chromium.org>
    251
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r111009 r111109  
    25142514    UChar* result = 0;
    25152515
    2516     // Do this in pieces to avoid massive reallocations if there is a large amount of text.
    2517     // Use system malloc for buffers since they can consume lots of memory and current TCMalloc is unable return it back to OS.
     2516    // The initial buffer size can be critical for performance: https://bugs.webkit.org/show_bug.cgi?id=81192
     2517#if PLATFORM(CHROMIUM) && PLATFORM(MAC)
     2518    static const unsigned cMaxSegmentSize = 1 << 15;
     2519#else
    25182520    static const unsigned cMaxSegmentSize = 1 << 16;
     2521#endif
    25192522    bufferLength = 0;
    25202523    typedef pair<UChar*, unsigned> TextSegment;
Note: See TracChangeset for help on using the changeset viewer.