Commit 1a3d539e authored by Yuzhu Shen's avatar Yuzhu Shen Committed by Commit Bot

Fix sync IPC perf tests.

- Actually uses IPC::SyncChannel to send sync messages.
- More accurately record the endtime.

After this change the Mojo sync IPC is faster than IPC-over-Mojo sync IPC:
(On linux z620; release build with profiling turned on.)

MojoChannelPerfTest.ChannelProxySyncPing
IPC_ChannelProxy_Perf_50000x_144  6507.49 ms

MojoInterfacePerfTest.MultiprocessSyncPing
IPC_MultiprocessSync_Perf_50000x_144  5283.86 ms

BUG=743263

Change-Id: Ie1834869b8d88e25a5986bdc9714132d6b7fc87b
Reviewed-on: https://chromium-review.googlesource.com/575032
Commit-Queue: Yuzhu Shen <yzshen@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487326}
parent 11a66767
......@@ -10,11 +10,13 @@
#include "base/process/process_metrics.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/perf_time_logger.h"
#include "base/test/test_io_thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_channel_mojo.h"
#include "ipc/ipc_sync_channel.h"
#include "ipc/ipc_test.mojom.h"
#include "ipc/ipc_test_base.h"
#include "mojo/edk/embedder/embedder.h"
......@@ -89,7 +91,9 @@ class PerformanceChannelListener : public Listener {
for (int i = 0; i < count_down_; ++i) {
std::string response;
sender_->Send(new TestMsg_SyncPing(payload_, &response));
DCHECK_EQ(response, payload_);
}
perf_logger_.reset();
base::MessageLoop::current()->QuitWhenIdle();
} else {
SendPong();
......@@ -302,9 +306,12 @@ class MojoChannelPerfTest : public IPCChannelMojoTestBase {
// Set up IPC channel and start client.
PerformanceChannelListener listener("ChannelProxy");
auto channel_proxy = IPC::ChannelProxy::Create(
base::WaitableEvent shutdown_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
auto channel_proxy = IPC::SyncChannel::Create(
TakeHandle().release(), IPC::Channel::MODE_SERVER, &listener,
io_thread_->task_runner());
io_thread_->task_runner(), false, &shutdown_event);
listener.Init(channel_proxy.get());
LockThreadAffinity thread_locker(kSharedCore);
......@@ -468,7 +475,9 @@ class MojoInterfacePerfTest : public mojo::edk::test::MojoTestBase {
for (int i = 0; i < count_down_; ++i) {
std::string response;
ping_receiver_->SyncPing(payload_, &response);
DCHECK_EQ(response, payload_);
}
perf_logger_.reset();
base::MessageLoop::current()->QuitWhenIdle();
} else {
ping_receiver_->Ping(payload_, base::Bind(&MojoInterfacePerfTest::OnPong,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment