Benchmarking#
pw_rpc: Efficient, low-code-size RPC system for embedded devices
pw_rpc provides an RPC service and Python utilities for measuring throughput,
latency, and resilience of an RPC deployment over its underlying transport.
pw.rpc.Benchmark service#
The Benchmark service provides a low-level RPC interface for sending bulk data
between client and server. The service is defined in pw_rpc/benchmark.proto.
A raw RPC implementation of the benchmark service is provided, suitable for any
system running pw_rpc.
To use the benchmark service in C++:
#include "pw_rpc/benchmark.h"
#include "pw_rpc/server.h"
constexpr pw::rpc::Channel kChannels[] = {/* ... */};
static pw::rpc::Server server(kChannels);
static pw::rpc::BenchmarkService benchmark_service;
void RegisterServices() { server.RegisterService(benchmark_service); }
Benchmark service definition#
syntax = "proto3";
package pw.rpc;
service Benchmark {
// The server responds with the payload the client sent.
rpc UnaryEcho(Payload) returns (Payload);
// The server responds to each request payload the client sends. The client
// stops the RPC by cancelling it.
rpc BidirectionalEcho(stream Payload) returns (stream Payload);
}
message Payload {
bytes payload = 1;
}
Stress testing#
The Benchmark service is also used to fuzz and stress-test the pw_rpc module
across multiple concurrent threads and fluctuating channel conditions.
To run the client-server fuzz stress test:
bazelisk test //pw_rpc/fuzz:cpp_client_server_fuzz_test