New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 758788 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Aug 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 715175



Sign in to add a comment

Mojo perf: IPC-over-mojo slows down significantly when the message is big

Project Member Reported by yzshen@chromium.org, Aug 25 2017

Issue description

I noticed that IPC-over-mojo slows down significantly when the message is big:

[ RUN      ] MojoChannelPerfTest.ChannelProxyPingPong
IPC_ChannelProxy_Perf_50000x_12	3776.38	ms
IPC_ChannelProxy_Perf_50000x_144	3724.65	ms
IPC_ChannelProxy_Perf_50000x_1728	4339.71	ms
IPC_ChannelProxy_Perf_12000x_20736	5292.21	ms
IPC_ChannelProxy_Perf_1000x_248832	4644.55	ms


[ RUN      ] MojoInterfacePerfTest.MultiprocessPingPong
IPC_Multiprocess_Perf_50000x_12	4905.66	ms
IPC_Multiprocess_Perf_50000x_144	3856.82	ms
IPC_Multiprocess_Perf_50000x_1728	4099.34	ms
IPC_Multiprocess_Perf_12000x_20736	2575.8	ms
IPC_Multiprocess_Perf_1000x_248832	1628.98	ms

Looking at the code, most of the time is spent in the two extra copies: IPC::Message <--> std::vector<uint8_t> (as argument of mojo method call Channel.Receive()).

It should be possible to make a typemap and eliminate these two copies.

 
Project Member

Comment 1 by bugdroid1@chromium.org, Aug 25 2017

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

commit a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5
Author: Yuzhu Shen <yzshen@chromium.org>
Date: Fri Aug 25 22:31:39 2017

IPC-over-mojo: Eliminate two buffer copies.

This CL:
- introduces a mojom type mojo.common.mojom.ReadOnlyBuffer and typemaps it to
base::span<const uint8_t>.
- changes ipc.mojom.Channel.Receive() to use this new type, so that we
can eliminate two buffer copies for each IPC message.

Please note that this approach relies on the fact that an incoming message stays
valid while making call to user code with the deseralized results.

=====================================================
Linux Z620; release component build

Before:
IPC_ChannelProxy_Perf_50000x_12 4247.97 ms
IPC_ChannelProxy_Perf_50000x_144  3626.01 ms
IPC_ChannelProxy_Perf_50000x_1728 4323.34 ms
IPC_ChannelProxy_Perf_12000x_20736  5419.29 ms
IPC_ChannelProxy_Perf_1000x_248832  4769.07 ms

After:
IPC_ChannelProxy_Perf_50000x_12 3770.21 ms
IPC_ChannelProxy_Perf_50000x_144  3710.2  ms
IPC_ChannelProxy_Perf_50000x_1728 4076.09 ms
IPC_ChannelProxy_Perf_12000x_20736  1461.84 ms
IPC_ChannelProxy_Perf_1000x_248832  1059.52 ms
=====================================================

BUG= 758788 

Change-Id: Id9d1ef0592482f6d75ff139feba6a36e79eb7e6d
Reviewed-on: https://chromium-review.googlesource.com/634450
Commit-Queue: Yuzhu Shen <yzshen@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#497565}
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/base/BUILD.gn
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/ipc/BUILD.gn
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/ipc/ipc.mojom
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/ipc/ipc_message_pipe_reader.cc
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/ipc/ipc_message_pipe_reader.h
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/ipc/ipc_mojo_bootstrap_unittest.cc
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/mojo/common/BUILD.gn
[add] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/mojo/common/read_only_buffer.mojom
[add] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/mojo/common/read_only_buffer.typemap
[add] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/mojo/common/read_only_buffer_struct_traits.h
[modify] https://crrev.com/a0a2b36b3ca41a53d0cf29bca93ae26c12e8fab5/mojo/common/typemaps.gni

Comment 2 by yzshen@chromium.org, Aug 25 2017

Status: Fixed (was: Started)

Sign in to add a comment