WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
102230
[v8] Improve worker.postMessage() string performance: avoid utf8 conversion
https://bugs.webkit.org/show_bug.cgi?id=102230
Summary
[v8] Improve worker.postMessage() string performance: avoid utf8 conversion
noel gordon
Reported
2012-11-14 07:26:29 PST
SerializedScriptValue uses of v8::String::Utf8Value stringValue(value) is hot code transferring strings to/from workers.
Attachments
Patch
(4.74 KB, patch)
2012-11-14 07:30 PST
,
noel gordon
no flags
Details
Formatted Diff
Diff
Patch
(16.58 KB, patch)
2012-11-22 06:49 PST
,
noel gordon
no flags
Details
Formatted Diff
Diff
Patch
(16.41 KB, patch)
2012-11-29 00:48 PST
,
noel gordon
no flags
Details
Formatted Diff
Diff
Patch
(16.64 KB, patch)
2012-11-29 18:09 PST
,
noel gordon
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
noel gordon
Comment 1
2012-11-14 07:30:17 PST
Created
attachment 174155
[details]
Patch
Adam Barth
Comment 2
2012-11-14 08:46:09 PST
Comment on
attachment 174155
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=174155&action=review
> Source/WebCore/bindings/v8/SerializedScriptValue.cpp:334 > + doWriteUint32(static_cast<uint32_t>(length * 2));
2 -> sizeof(UChar) ?
> Source/WebCore/bindings/v8/SerializedScriptValue.cpp:335 > + ensureSpace(length * 2);
Maybe we should put "length * 2" into a local variable since we use it a bunch? Perhaps size?
Joshua Bell
Comment 3
2012-11-14 08:54:53 PST
I filed
https://bugs.webkit.org/show_bug.cgi?id=102243
to track the issue this will cause with IndexedDB. We could land this first, but ideally 102243 would land at the same time or within a few days.
Joshua Bell
Comment 4
2012-11-14 08:58:13 PST
wireFormatVersion (line 244) needs to be incremented.
Alec Flett
Comment 5
2012-11-14 10:32:03 PST
Please wait for
bug 96818
so you have a place to add tests and support backwards-compatible changes.
noel gordon
Comment 6
2012-11-19 23:18:28 PST
(In reply to
comment #4
)
> wireFormatVersion (line 244) needs to be incremented.
Considering
bug 72198
and
bug 76803
, both of which added new serialization tag definitions, then why increment? Seems we've never done so before.
Joshua Bell
Comment 7
2012-11-20 09:29:23 PST
(In reply to
comment #6
)
> (In reply to
comment #4
) > > wireFormatVersion (line 244) needs to be incremented. > > Considering
bug 72198
and
bug 76803
, both of which added new serialization tag definitions, then why increment? Seems we've never done so before.
The scenario we need to account for is: * User installs build N+1 * User visits site using IndexedDB which writes SSVs to disk * User "downgrades" to build N, without removing the "profile" (cookies, DBs, etc) * User visits site; IndexedDB opens the backing store; some SSVs can't be parsed, surfaced as seemingly random data errors or inconsistencies This scenario is unfortunately common enough that we've had to account for it by detecting the downgrade scenario. Our response in the IndexedDB code is rather severe (blow away the database) but the alternative is to block that origin's use of IDB, or surface what appears to web apps as data corruption. The frequency of this scenario was not apparent to us until recently, or we would have implemented code such as
https://bugs.webkit.org/show_bug.cgi?id=102243
earlier. Suggestions for alternate approaches are welcome.
noel gordon
Comment 8
2012-11-22 06:35:13 PST
Thanks Josuha, I suppose IDB is like a really big cookie and users can blow their cookies (and IDB's) away any time. Applications have to deal with it: IDB storage is persistent, but it's not permanent.
noel gordon
Comment 9
2012-11-22 06:40:31 PST
(In reply to
comment #2
)
> (From update of
attachment 174155
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=174155&action=review
> > > Source/WebCore/bindings/v8/SerializedScriptValue.cpp:334 > > + doWriteUint32(static_cast<uint32_t>(length * 2)); > > 2 -> sizeof(UChar) ?
Done.
> > Source/WebCore/bindings/v8/SerializedScriptValue.cpp:335 > > + ensureSpace(length * 2); > > Maybe we should put "length * 2" into a local variable since we use it a bunch? Perhaps size?
Good suggestion, I used size. I also had to account for the length being VarInt encoded when working out if a paddingTag should be added.
noel gordon
Comment 10
2012-11-22 06:49:05 PST
Created
attachment 175667
[details]
Patch
Alec Flett
Comment 11
2012-11-28 15:54:26 PST
Comment on
attachment 175667
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175667&action=review
> Source/WebCore/bindings/v8/SerializedScriptValue.cpp:247 > +// Version 1: Version numbers manifested in space-time.
How about Version 0: Initial version, without explicit support for version numbers. Version 1: support for object references (cycle detection) Version 2:...
> LayoutTests/platform/chromium/fast/storage/serialized-script-value.html:149 > +var unicodeObject = {a: 'a', u: String.fromCharCode(0x03B1,0x03B2)};
you're going to need to add a backwards-compatible test here too - you'll have to run the test without your patch to generate the value first, then set the 3rd parameter to testSerialization to 'true'
noel gordon
Comment 12
2012-11-28 18:30:50 PST
(In reply to
comment #11
)
> (From update of
attachment 175667
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=175667&action=review
> > > Source/WebCore/bindings/v8/SerializedScriptValue.cpp:247 > > +// Version 1: Version numbers manifested in space-time. > > How about > Version 0: Initial version, without explicit support for version numbers. > Version 1: support for object references (cycle detection) > Version 2:...
How about (refer
comment 6
) I just write // Version 2: Added StringUCharTag for UChar v8 strings. since that's the only real fact I have. "support for object references (cycle detection)" does not cover what happened before version 2.
noel gordon
Comment 13
2012-11-29 00:48:59 PST
Created
attachment 176668
[details]
Patch
noel gordon
Comment 14
2012-11-29 00:53:46 PST
(In reply to
comment #11
)
> > LayoutTests/platform/chromium/fast/storage/serialized-script-value.html:149 > > +var unicodeObject = {a: 'a', u: String.fromCharCode(0x03B1,0x03B2)}; > > you're going to need to add a backwards-compatible test here too - you'll have to run the test without your patch to generate the value first, then set the 3rd parameter to testSerialization to 'true'
ok, I grabbed data for the test without my patch, and added that old data as the third argument of the test. Didn't use a 'true', hope this is correct.
noel gordon
Comment 15
2012-11-29 01:00:23 PST
(In reply to
comment #14
) Also fixed the existing test on
http://trac.webkit.org/changeset/136085
so I could grab the data.
noel gordon
Comment 16
2012-11-29 18:09:10 PST
Created
attachment 176875
[details]
Patch
Alec Flett
Comment 17
2012-11-30 13:28:41 PST
thanks for updating the tests - they lgtm now. (and yes, not sure why I thought the 3rd param was true/false) (I'm realizing that what we really need is to support a whole list of "oldFormat" rather than just one - i.e. we should be supporting all the 0x01-prefixed values here. But you don't need to address that in this patch)
noel gordon
Comment 18
2012-12-04 16:44:04 PST
(In reply to
comment #17
)
> thanks for updating the tests - they lgtm now. (and yes, not sure why I thought the 3rd param was true/false)
: ) no worries.
> (I'm realizing that what we really need is to support a whole list of "oldFormat" rather than just one - i.e. we should be supporting all the 0x01-prefixed values here. But you don't need to address that in this patch)
Indeed.
noel gordon
Comment 19
2012-12-04 16:44:58 PST
(In reply to
comment #3
)
> I filed
https://bugs.webkit.org/show_bug.cgi?id=102243
to track the issue this will cause with IndexedDB. We could land this first, but ideally 102243 would land at the same time or within a few days.
So is there anything more I need do here Josuha?
Joshua Bell
Comment 20
2012-12-04 16:47:30 PST
(In reply to
comment #19
)
> So is there anything more I need do here Josuha?
Not that I know of - I'd say go ahead and land it! I have 102243 ready to go... apart from tests and those will probably have to live in Chromium anyway. Users downgrading w/o deleting their profiles is not supported, just common enough that I want to be proactive so we don't have to land these together.
Eric Seidel (no email)
Comment 21
2012-12-04 16:57:39 PST
This looks reasonable, but I would love to have Dan Carney comment, given that he's been working in the v8-specific 8-bit string code so much lately.
Eric Seidel (no email)
Comment 22
2012-12-04 16:59:19 PST
Actually, this has little to do with v8-8bit strings, so Dan's comments although welcome, are not necessary.
Eric Seidel (no email)
Comment 23
2012-12-04 17:02:40 PST
Comment on
attachment 176875
[details]
Patch If Alec says LGTM, then LGTM too.
WebKit Review Bot
Comment 24
2012-12-04 20:29:18 PST
Comment on
attachment 176875
[details]
Patch Clearing flags on attachment: 176875 Committed
r136624
: <
http://trac.webkit.org/changeset/136624
>
WebKit Review Bot
Comment 25
2012-12-04 20:29:24 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