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 <[email protected]>
Reviewed-by: Tom Sepez <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Cr-Commit-Position: refs/heads/master@{#497565}
diff --git a/ipc/ipc.mojom b/ipc/ipc.mojom
index f986c47..3ab4d4ef 100644
--- a/ipc/ipc.mojom
+++ b/ipc/ipc.mojom
@@ -4,6 +4,8 @@
module IPC.mojom;
+import "mojo/common/read_only_buffer.mojom";
+
// NOTE: This MUST match the value of MSG_ROUTING_NONE in src/ipc/ipc_message.h.
const int32 kRoutingIdNone = -2;
@@ -31,7 +33,8 @@
SetPeerPid(int32 pid);
// Transmits a classical Chrome IPC message.
- Receive(array<uint8> data, array<SerializedHandle>? handles);
+ Receive(mojo.common.mojom.ReadOnlyBuffer data,
+ array<SerializedHandle>? handles);
// Requests a Channel-associated interface.
GetAssociatedInterface(string name, associated GenericInterface& request);