New issue
Advanced search Search tips

Issue 769907 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Reduce number of times data is copies when postMessaging

Project Member Reported by mek@chromium.org, Sep 28 2017

Issue description

Ideally for every postMessage related API we'd just have 2 copies of the SSV data: a first copy directly from the SSV internal buffer into the IPC data stream, and a second copy directly from the incoming IPC data stream into SSVs internal buffer.

With proper struct traits and updating all postMessage related mojo calls to use the MessagePortMessage mojo struct this should be fairly easy to achieve.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Oct 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f259e4349a5f63f4000e2b85e56d902df2d16906

commit f259e4349a5f63f4000e2b85e56d902df2d16906
Author: Marijn Kruisselbrink <mek@chromium.org>
Date: Wed Oct 04 23:07:28 2017

Directly serialize messageport messages to/from SerializedScriptValue.

I believe this reduces the number of copies of the data to its minimum
(of one copy from the SSV into a mojo message, and one copy from the mojo
message into a SSV).

In future CLs these same struct traits will also be used to optimize
other postMessage APIs, and to ultimately have one place where
serialization and deserialization of postMessage messages is done, making
it easier to add things like Blob handles and possible shared array buffer
handles to messages.

Bug:  769907 
Change-Id: Iae57c33dd9baa06fe8860b64a43846f2962e319a
Reviewed-on: https://chromium-review.googlesource.com/667401
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506555}
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/PRESUBMIT.py
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/BUILD.gn
[add] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/BlinkMessagePortMessage.cpp
[add] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/BlinkMessagePortMessage.h
[add] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/BlinkMessagePortMessageStructTraits.cpp
[add] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/BlinkMessagePortMessageStructTraits.h
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/MessagePort.cpp
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/MessagePort.h
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/Source/core/dom/OWNERS
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/common/BUILD.gn
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/common/message_port/message_port_channel.cc
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/common/message_port/message_port_channel.h
[modify] https://crrev.com/f259e4349a5f63f4000e2b85e56d902df2d16906/third_party/WebKit/common/message_port/message_port_message.h

Comment 2 by mek@chromium.org, Jan 10 2018

Status: Fixed (was: Started)
Don't think there is much room for improvement left here.
In-process MessagePort.postMessage will just serialize to SSV, and then deserialize from the same SSV instance, and cross process the SSV data is copied into the mojo messagepipe, and then out of it directly from/to the SSV.

Sign in to add a comment