Skip to content

Commit

Permalink
adds h2 implementation for grpc ping
Browse files Browse the repository at this point in the history
  • Loading branch information
brayniac committed Jul 23, 2024
1 parent e8102b7 commit 0ce5ba9
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 21 deletions.
17 changes: 13 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ tonic = "0.11"
warp = "0.3.6"
zipf = "7.0.1"
flate2 = "1.0.28"
pin-project = "1.1.5"
h2 = "0.4.5"
http = "1.1.0"

[build-dependencies]
tonic-build = "0.11"
Expand All @@ -70,7 +73,7 @@ debug = true
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
codegen-units = 16

[profile.bench]
opt-level = 3
Expand Down
4 changes: 2 additions & 2 deletions configs/grpc_ping.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[general]
# specify the protocol to be used
protocol = "grpc_ping"
protocol = "http2_ping"
# the interval for stats integration and reporting
interval = 60
# the number of intervals to run the test for
Expand Down Expand Up @@ -44,7 +44,7 @@ log_max_size = 1073741824
[target]
# specify one or more endpoints as IP:PORT pairs
endpoints = [
"http://127.0.0.1:12321",
"http://cache00:12321",
]

[client]
Expand Down
14 changes: 9 additions & 5 deletions configs/ping.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@

[general]
# specify the protocol to be used
protocol = "ping"
# should be one of:
# ping - ascii ping/pong over TCP (w/ optional TLS)
# grpc_ping - ping/pong using GRPC over HTTP(s)/2
# http2_ping - ping/pong implemented using HTTP(s)/2 GET
protocol = "grpc_ping"
# the interval for stats integration and reporting
interval = 60
interval = 1
# the number of intervals to run the test for
duration = 300
# run the admin thread with a HTTP listener at the address provided, this allows
Expand Down Expand Up @@ -44,14 +48,14 @@ log_max_size = 1073741824
[target]
# specify one or more endpoints as IP:PORT pairs
endpoints = [
"127.0.0.1:12321",
"http://127.0.0.1:8080",
]

[client]
# number of threads used to drive client requests
threads = 4
# the total number of connections to each endpoint
poolsize = 20
poolsize = 100
# the connect timeout in milliseconds
connect_timeout = 10000
# set the timeout in milliseconds
Expand All @@ -63,7 +67,7 @@ threads = 1

[workload.ratelimit]
# set a global ratelimit for the workload
start = 10_000
#start = 1

# Note, even though the command does not use keys, it's still a member of a
# keyspace.
Expand Down
8 changes: 4 additions & 4 deletions src/clients/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use hyper::{Request, Uri};
use std::future::Future;

#[derive(Clone)]
struct Queue<T> {
pub struct Queue<T> {
tx: async_channel::Sender<T>,
rx: async_channel::Receiver<T>,
}
Expand Down Expand Up @@ -62,7 +62,7 @@ pub fn launch_tasks(runtime: &mut Runtime, config: Config, work_receiver: Receiv
}

#[derive(Clone)]
struct TokioExecutor;
pub struct TokioExecutor;

impl<F> Executor<F> for TokioExecutor
where
Expand All @@ -74,7 +74,7 @@ where
}
}

async fn pool_manager(endpoint: String, config: Config, queue: Queue<SendRequest<Empty<Bytes>>>) {
pub async fn pool_manager(endpoint: String, config: Config, queue: Queue<SendRequest<Empty<Bytes>>>) {
let connector = Connector::new(&config).expect("failed to init connector");
let mut sender = None;

Expand Down Expand Up @@ -181,7 +181,7 @@ async fn task(
.header(hyper::header::HOST, authority.as_str())
.header(
hyper::header::USER_AGENT,
&format!("rpc-perf/5.0.0-alpha (request; seq:{sequence})"),
&format!("rpc-perf/{} (request; seq:{sequence})", env!("CARGO_PKG_VERSION")),
)
.body(Empty::<Bytes>::new())
.expect("failed to build request")
Expand Down
8 changes: 5 additions & 3 deletions src/clients/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use tokio::time::{timeout, Duration};
use std::io::{Error, ErrorKind, Result};
use std::time::Instant;

mod grpc_ping;
mod http1;
mod http2;
mod memcache;
Expand All @@ -33,22 +32,25 @@ pub fn launch_clients(config: &Config, work_receiver: Receiver<WorkItem>) -> Opt

match config.general().protocol() {
Protocol::GrpcPing => {
clients::grpc_ping::launch_tasks(&mut client_rt, config.clone(), work_receiver)
clients::ping::grpc::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Http1 => {
clients::http1::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Http2 => {
clients::http2::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Http2Ping => {
clients::ping::http2::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Memcache => {
clients::memcache::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Momento => {
clients::momento::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Ping => {
clients::ping::launch_tasks(&mut client_rt, config.clone(), work_receiver)
clients::ping::ascii::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Resp => {
clients::redis::launch_tasks(&mut client_rt, config.clone(), work_receiver)
Expand Down
2 changes: 1 addition & 1 deletion src/clients/ping.rs → src/clients/ping/ascii.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::*;
use crate::clients::*;
use crate::net::Connector;
use protocol_ping::{Compose, Parse, Request, Response};
use session::{Buf, BufMut, Buffer};
Expand Down
2 changes: 1 addition & 1 deletion src/clients/grpc_ping.rs → src/clients/ping/grpc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::*;
use crate::clients::*;
use tonic::transport::Channel;

use pingpong::ping_client::PingClient;
Expand Down
Loading

0 comments on commit 0ce5ba9

Please sign in to comment.