Changeset 173080 in webkit


Ignore:
Timestamp:
Aug 28, 2014 2:08:26 PM (10 years ago)
Author:
psolanki@apple.com
Message:

WebContent hangs under SharedBuffer::duplicateDataBufferIfNecessary() while browsing some websites
https://bugs.webkit.org/show_bug.cgi?id=136347
<rdar://problem/18073745>

Reviewed by Andreas Kling.

When passing data to ImageIO, we create a copy if we have to reallocate the buffer. We would
set the size of the new buffer to be the size of the SharedBuffer data. This causes memory
churn since we would create a new buffer for every data chunk we get. Fix this by at least
doubling the capacity of the buffer when we duplicate it.

  • platform/SharedBuffer.cpp:

(WebCore::SharedBuffer::duplicateDataBufferIfNecessary):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173079 r173080  
     12014-08-28  Pratik Solanki  <psolanki@apple.com>
     2
     3        WebContent hangs under SharedBuffer::duplicateDataBufferIfNecessary() while browsing some websites
     4        https://bugs.webkit.org/show_bug.cgi?id=136347
     5        <rdar://problem/18073745>
     6
     7        Reviewed by Andreas Kling.
     8
     9        When passing data to ImageIO, we create a copy if we have to reallocate the buffer. We would
     10        set the size of the new buffer to be the size of the SharedBuffer data. This causes memory
     11        churn since we would create a new buffer for every data chunk we get. Fix this by at least
     12        doubling the capacity of the buffer when we duplicate it.
     13
     14        * platform/SharedBuffer.cpp:
     15        (WebCore::SharedBuffer::duplicateDataBufferIfNecessary):
     16
    1172014-08-28  Dan Bernstein  <mitz@apple.com>
    218
  • trunk/Source/WebCore/platform/SharedBuffer.cpp

    r172790 r173080  
    2828#include "SharedBuffer.h"
    2929
     30#include <algorithm>
    3031#include <wtf/PassOwnPtr.h>
    3132#include <wtf/unicode/UTF8.h>
     
    352353void SharedBuffer::duplicateDataBufferIfNecessary() const
    353354{
    354     if (m_buffer->hasOneRef() || m_size <= m_buffer->data.capacity())
     355    size_t currentCapacity = m_buffer->data.capacity();
     356    if (m_buffer->hasOneRef() || m_size <= currentCapacity)
    355357        return;
    356358
     359    size_t newCapacity = std::max(static_cast<size_t>(m_size), currentCapacity * 2);
    357360    RefPtr<DataBuffer> newBuffer = adoptRef(new DataBuffer);
    358     newBuffer->data.reserveInitialCapacity(m_size);
     361    newBuffer->data.reserveInitialCapacity(newCapacity);
    359362    newBuffer->data = m_buffer->data;
    360363    m_buffer = newBuffer.release();
Note: See TracChangeset for help on using the changeset viewer.