WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
117458
XMLHttpRequest performs too many copies for ArrayBuffer results
https://bugs.webkit.org/show_bug.cgi?id=117458
Summary
XMLHttpRequest performs too many copies for ArrayBuffer results
Ryosuke Niwa
Reported
2013-06-10 18:01:35 PDT
Consider merging
https://chromium.googlesource.com/chromium/blink/+/bed266aa5a43f7c080c87e527bd35e2b80ecc7b7
This cuts - two memsets (in ArrayBuffer::create and SharedBuffer::m_buffer::resize) - one copy (SharedBuffer::m_buffer to ArrayBufferContents::m_data) - one allocation (SharedBuffer::m_buffer) Copy for consolidation still happens from m_segments to m_data instead of from m_segments to m_buffer. Quick localhost benchmark showed ~10% speedup.
Attachments
Blink's implementation
(4.87 KB, patch)
2014-02-03 03:35 PST
,
Wojciech Bielawski
no flags
Details
Formatted Diff
Diff
Blink's implementation
(5.56 KB, patch)
2014-02-03 05:54 PST
,
Wojciech Bielawski
no flags
Details
Formatted Diff
Diff
Blink's implementation
(5.56 KB, patch)
2014-02-04 02:14 PST
,
Wojciech Bielawski
ap
: review+
Details
Formatted Diff
Diff
Blink's implementation
(5.53 KB, patch)
2014-02-05 02:08 PST
,
Wojciech Bielawski
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2013-06-10 23:48:22 PDT
Sounds like a good idea, but the patch cannot be landed as is, at least because of incorrect naming (getAsArrayBuffer is not a proper name for a getter).
Wojciech Bielawski
Comment 2
2014-01-27 05:46:07 PST
Does anyone working on it? If not I will.
Wojciech Bielawski
Comment 3
2014-02-03 03:35:40 PST
Created
attachment 222975
[details]
Blink's implementation
Sergio Villar Senin
Comment 4
2014-02-03 03:49:56 PST
Comment on
attachment 222975
[details]
Blink's implementation View in context:
https://bugs.webkit.org/attachment.cgi?id=222975&action=review
A couple of nits
> Source/JavaScriptCore/ChangeLog:7 > +
Although it's nice to refer to the source of the change, the ChangeLog should include a description of the patch at least including the savings we get.
> Source/WebCore/platform/SharedBuffer.cpp:295 > + return arrayBuffer;
I think it's a good idea to use arrayBuffer.release() here.
Wojciech Bielawski
Comment 5
2014-02-03 05:54:19 PST
Created
attachment 222978
[details]
Blink's implementation
Alexey Proskuryakov
Comment 6
2014-02-03 09:47:40 PST
Comment on
attachment 222978
[details]
Blink's implementation View in context:
https://bugs.webkit.org/attachment.cgi?id=222978&action=review
> Source/JavaScriptCore/runtime/ArrayBuffer.h:99 > + // Only for use by Uint8ClampedArray::createUninitialized and SharedBuffer::getAsArrayBuffer.
getAsArrayBuffer is mentioned in this comment, and in two ChangeLogs, but this function no longer exists.
Alexey Proskuryakov
Comment 7
2014-02-03 09:48:58 PST
How did you decide that it's fine to override what's been requested in this comment? - // Only for use by Uint8ClampedArray::createUninitialized. + // Only for use by Uint8ClampedArray::createUninitialized and SharedBuffer::getAsArrayBuffer.
Alexey Proskuryakov
Comment 8
2014-02-03 09:55:13 PST
I understand that you need some way to merge the data into a buffer, but I don't know the rationale for this comment. Seems like whoever added it wanted us to not add more exceptions even in cases where we thought that we needed them.
Wojciech Bielawski
Comment 9
2014-02-03 09:57:17 PST
(In reply to
comment #7
)
> How did you decide that it's fine to override what's been requested in this comment? > > - // Only for use by Uint8ClampedArray::createUninitialized. > + // Only for use by Uint8ClampedArray::createUninitialized and SharedBuffer::getAsArrayBuffer.
It was in original commit. Shall I remove it?
Wojciech Bielawski
Comment 10
2014-02-04 02:14:36 PST
Created
attachment 223087
[details]
Blink's implementation
Wojciech Bielawski
Comment 11
2014-02-04 02:21:33 PST
(In reply to
comment #8
)
> I understand that you need some way to merge the data into a buffer, but I don't know the rationale for this comment. Seems like whoever added it wanted us to not add more exceptions even in cases where we thought that we needed them.
I assume that the author of original commit didn't find any inconsistency in creaateUninitialized code reusage. This comment also seems like justification does it neccessary at all. I could remove that comment at all since creaateUninitialized is public anyway.
Filip Pizlo
Comment 12
2014-02-04 07:01:47 PST
Comment on
attachment 223087
[details]
Blink's implementation View in context:
https://bugs.webkit.org/attachment.cgi?id=223087&action=review
LGTM. Did you mean to mark this as r?
> Source/JavaScriptCore/runtime/ArrayBuffer.h:99 > - // Only for use by Uint8ClampedArray::createUninitialized. > + // Only for use by Uint8ClampedArray::createUninitialized and SharedBuffer::createArrayBuffer.
I agree with this change. The reason why createUninitialized() is public is because it was impractical to use friends because of the template madness going on in Uint8ClamperArray. This comment is a kind of unenforced "friend" replacement.
> Source/WebCore/platform/SharedBuffer.cpp:289 > + ASSERT_NOT_REACHED();
I prefer RELEASE_ASSERT_NOT_REACHED().
Alexey Proskuryakov
Comment 13
2014-02-04 10:13:27 PST
Comment on
attachment 223087
[details]
Blink's implementation View in context:
https://bugs.webkit.org/attachment.cgi?id=223087&action=review
Nice!
> Source/WebCore/platform/SharedBuffer.cpp:279 > + RefPtr<ArrayBuffer> arrayBuffer = ArrayBuffer::createUninitialized(static_cast<unsigned>(size()), 1);
Nit: sizeof(char) would make this code slightly easier to read - with "1", most people will need to open another file to check what createUninitialized() arguments are.
>> Source/WebCore/platform/SharedBuffer.cpp:289 >> + ASSERT_NOT_REACHED(); > > I prefer RELEASE_ASSERT_NOT_REACHED().
We don't have a lot of these in WebCore, and I actually don't think that we should. Unlike in JSC, many logic errors don't cause huge unintended consequences such as security bugs, and it's better to have a web site with some functionality broken than a WebProcess crash. In this particular case, the failure is pretty benign - we essentially fail the load, which could happen for other reasons, like a network failure.
Wojciech Bielawski
Comment 14
2014-02-05 02:08:23 PST
Created
attachment 223223
[details]
Blink's implementation
WebKit Commit Bot
Comment 15
2014-02-05 04:53:54 PST
Comment on
attachment 223223
[details]
Blink's implementation Clearing flags on attachment: 223223 Committed
r163444
: <
http://trac.webkit.org/changeset/163444
>
WebKit Commit Bot
Comment 16
2014-02-05 04:53:57 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug