Skip to content

grpc-benchmark: Worker and server implementation#2706

Open
arjan-bal wants to merge 9 commits into
grpc:masterfrom
arjan-bal:grpc-benchmark-server
Open

grpc-benchmark: Worker and server implementation#2706
arjan-bal wants to merge 9 commits into
grpc:masterfrom
arjan-bal:grpc-benchmark-server

Conversation

@arjan-bal

@arjan-bal arjan-bal commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Contributes to: #2666

This PR adds the worker and the benchmarking server implementations. Both components use tonic and prost for now, as the gRPC server is still under development. The benchmarking client that uses gRPC will be added in a follow-up PR.

@arjan-bal arjan-bal marked this pull request as draft June 26, 2026 07:46
@arjan-bal arjan-bal marked this pull request as ready for review June 29, 2026 11:15
@arjan-bal arjan-bal requested review from dfawley and ejona86 June 29, 2026 11:15

@ejona86 ejona86 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't get all the way through; sending what I have.

Comment thread grpc-benchmark/src/main.rs Outdated
Comment thread grpc-benchmark/src/server.rs Outdated
@arjan-bal arjan-bal force-pushed the grpc-benchmark-server branch 2 times, most recently from 38faf3f to 821047d Compare June 30, 2026 09:42
@arjan-bal arjan-bal force-pushed the grpc-benchmark-server branch from 821047d to 7af7498 Compare June 30, 2026 09:49
@arjan-bal arjan-bal requested a review from ejona86 June 30, 2026 09:58
println!("Server creation requested.");

if benchmark_server.take().is_some() {
eprintln!("Server setup received when server already exists, shutting down the existing server");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does replacing the server actually work? I'd expect start() to fail because the port is already in use. I think we need to set benchmark_server = None here. And that might still be racy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you abort the task in drop, instead of using the Notify, then it should be fine, but there might still be stuff going on at the OS level that prevents it from being reused immediately. I would expect that should be up to the driver to not do that, though, right?


let mut server_builder = Server::builder();
// Parse security config.
if let Some(securit_params) = config.security_params {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/securit/security/

.serve_with_shutdown(addr, async {
rx.recv().await;
// Wait for the quit_worker response to be sent.
time::sleep(Duration::from_secs(1)).await;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we sleep 1 second here? Will the client fail if the server hard shuts down before the call competes successfully or something?


pub async fn run_worker(worker_port: u16) -> Result<(), Box<dyn std::error::Error>> {
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), worker_port);
let (tx, mut rx) = mpsc::channel(1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: quit_tx, mut quit_rx?

Comment on lines +34 to +36
use nix::sys::resource::UsageWho;
use nix::sys::resource::getrusage;
use nix::sys::time::TimeValLike;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the philosophy for this? When do we use at a local scope like this vs. at the file level? It would probably be good to have some kind of guideline if it's not a hard rule like "always use at the file level".

println!("Server creation requested.");

if benchmark_server.take().is_some() {
eprintln!("Server setup received when server already exists, shutting down the existing server");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you abort the task in drop, instead of using the Notify, then it should be fine, but there might still be stuff going on at the OS level that prevents it from being reused immediately. I would expect that should be up to the driver to not do that, though, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants