New issue
Advanced search Search tips

Issue 701843 link

Starred by 2 users

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

In-process postMessage can be more efficient if the message is a string

Project Member Reported by jbroman@chromium.org, Mar 15 2017

Issue description

Due to serialization, most of the time we make at least two copies in the process of sending a message (this is necessary in general, because we cannot synchronize the sender and receiver).

1. (zero-copy) If the sender and receiver are in the same isolate (e.g. two frames in the same page), then we can take a zero-copy path by just passing a handle to the v8 string. Unlike objects, strings are not attached to a particular context. This makes the cost constant in the length of the string.

2. (one-copy) If the sender and receiver are in the same process, then we can copy the string into an isolated copy WTF::String that can be sent to another thread, and then create an external v8 string from that (without a further copy).

These both seem fairly straightforward if MessageEvent is refactored slightly (it already supports a variety of kinds of objects as data, not just SerializedScriptValue).

These don't help more complicated objects, though, so cases like {someKey:"hugestringhere"} aren't improved. It would be possible to generalize this to work inside objects (and avoid a performance cliff), by giving v8::ValueSerializer an ability to delegate large strings to its delegate (and then hanging these off the SerializedScriptValue, like transferables).

I already have the quick and easy (1) working (and it's fast -- probably slightly faster yet because we don't have to set up a serializer at all), but it's a little weird to end up with a state such that strings are fast, but only if you _just_ send a string.
 
Status: Available (was: Started)
Implemented with V8 support (to allow items inside objects), and this works, but for the worker case doesn't end up being as much of a win as one would hope, because if you do it a few times the GC jank (which is the major jank) seems to end up being similar (on both Linux/Z620 and Android/Nexus4).

This might be worth investigating in more detail at some later time, but I'd hoped for a clearer win here. For posterity:

V8: https://codereview.chromium.org/2768923002
Blink: https://codereview.chromium.org/2768113002

I'm going to shelve for now unless we get evidence in the future that this is worth pursuing further.
Owner: ----
Project Member

Comment 3 by sheriffbot@chromium.org, Jun 7 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment