Bug 47692 - [v8] REGRESSION(69688) XMLHttpRequest responseText is now accumulated in a flat buffer, not a rope
Summary: [v8] REGRESSION(69688) XMLHttpRequest responseText is now accumulated in a fl...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-14 14:00 PDT by James Robinson
Modified: 2014-03-10 16:24 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Robinson 2010-10-14 14:00:26 PDT
An XMLHttpRequest's responseText attribute used to be stored in a ScriptString, which internally stored the response string as a sequence of UTF-16 StringImpl's appended into a V8 string using V8::String::Concat().  This meant that the typical use case where the .responseText is built up by a sequence of append() calls we never had to copy the buffer, we just passed in a series of UTF-16 segments to V8 and let it manage the set.  After 69668, .responseText is built using the StringBuilder class which appends into a flat buffer and copies when necessary (looks like it uses a 2x growth factor currently).

This regresses performance and memory in a few ways that we should address.  This is also a good opportunity to examine other strategies for how to manage .responseText such as keeping raw bytes around and lazily decoding to UTF-16.

See https://bugs.webkit.org/show_bug.cgi?id=29909 for the initial implementation of V8's ScriptString.
Comment 1 James Robinson 2010-10-14 15:39:29 PDT
We (gbarra and I) chatted about this some in IRC.  The conclusion is that the best thing to do for now is probably to #ifdef a V8 implementation in XMLHttpRequest that has the useful properties.  According to Dave Levin this has implications for the inspector as well since it has the ability to log XHR response bodies.  We'll want to be careful that the inspector is referencing an efficient representation of the string and not accidentally flattening a buffer all the time or something else silly.