Skip to content

impl(pubsub): add publish hedging benchmark tool - #6804

Open
suzmue wants to merge 1 commit into
googleapis:mainfrom
suzmue:pubsub-hedging-benchmark
Open

suzmue wants to merge 1 commit into
googleapis:mainfrom
suzmue:pubsub-hedging-benchmark

Conversation

@suzmue

@suzmue suzmue commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Add a standalone benchmark binary in src/pubsub/benchmarks/hedging to measure publisher throughput and tail latency under simulated network tail latencies (fast, degraded, and stall modes).

The benchmark includes an in-process mock server backed by pubsub-grpc-mock which tracks total and hedged publish RPC counts via telemetry headers.

Hedging configuration is not yet added because we do not yet support it in the publisher.

For #6776

@suzmue
suzmue requested a review from a team as a code owner September 14, 2026 21:30
@product-auto-label product-auto-label Bot added the api: pubsub Issues related to the Pub/Sub API. label Sep 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new benchmark tool, pubsub-hedging, to evaluate Cloud Pub/Sub publish latency and request hedging against a simulated tail-latency mock server. The review feedback identifies three key issues: an ineffective timeout mechanism when draining the benchmark's JoinSet that can lead to indefinite blocking, a potential division-by-zero panic if the message_rate argument is set to zero, and a lack of a timeout during the warmup phase's task draining loop.

Comment thread src/pubsub/benchmarks/hedging/src/main.rs
Comment thread src/pubsub/benchmarks/hedging/src/args.rs Outdated
Comment thread src/pubsub/benchmarks/hedging/src/main.rs Outdated
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.97%. Comparing base (65e1eb1) to head (cb1213f).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6804   +/-   ##
=======================================
  Coverage   96.97%   96.97%           
=======================================
  Files         325      325           
  Lines      106426   106426           
=======================================
+ Hits       103204   103209    +5     
+ Misses       3222     3217    -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suzmue
suzmue marked this pull request as draft September 14, 2026 22:15
@suzmue

suzmue commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new benchmark crate, pubsub-hedging, designed to evaluate Cloud Pub/Sub message publishing latency with and without request hedging against an in-process simulated tail latency server. The changes include adding the benchmark orchestrator, CLI argument parsing, a mock server with configurable latencies, and statistics calculation utilities, along with workspace configuration updates. The review feedback suggests explicitly aborting warmup tasks if they timeout to prevent them from running in the background and polluting the benchmark results.

Comment thread src/pubsub/benchmarks/hedging/src/main.rs Outdated
@suzmue
suzmue marked this pull request as ready for review September 15, 2026 01:32
@suzmue
suzmue force-pushed the pubsub-hedging-benchmark branch from 5f20420 to 9c4d8fb Compare September 15, 2026 02:57
Add a standalone benchmark binary in `src/pubsub/benchmarks/hedging` to
measure publisher throughput and latency percentiles under simulated
network tail latencies (fast, degraded, and stall modes).

The benchmark includes an in-process mock server backed by
`pubsub-grpc-mock` which tracks total and hedged publish RPC counts via
telemetry headers, running unbatched messages (1 message per batch)
with a configurable warmup phase.
@suzmue
suzmue force-pushed the pubsub-hedging-benchmark branch from 9c4d8fb to cb1213f Compare September 15, 2026 03:08

@dbolduc dbolduc 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.

I wonder how well this models prod

let mut interval = tokio::time::interval(interval_duration);
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Burst);

if !args.warmup.is_zero() {

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.

optional nit: factor out warmup into like warmup(...).await? or something just so main is more streamlined

self.config.degraded_latency
} else {
self.config.stall_latency
};

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.

comment: Oh so we are simulating server behavior, not hitting prod. hmm. I feel like we already know the answers to the test.

There is value in simulating things that do happen but are hard to reproduce.

use std::time::Duration;
use tokio::task::JoinHandle;

use pubsub_grpc_mock::google::pubsub::v1::publisher_server::{Publisher, PublisherServer};

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.

comment: Ah we can use the generated gRPC server directly. IIRC our mocking framework only supports one service bc I am lazy.

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

Labels

api: pubsub Issues related to the Pub/Sub API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants