Skip to content

test(spanner): unflake ReadBenchmark by isolating mock server and fixing heap leak - #14417

Merged
sakthivelmanii merged 1 commit into
mainfrom
fix-spanner-benchmark-process-split
Sep 18, 2026
Merged

sakthivelmanii merged 1 commit into
mainfrom
fix-spanner-benchmark-process-split

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor
  • Add StandaloneBenchmarkServer and update ReadBenchmark (along with the Maven benchmark profile) to connect to an external gRPC mock server when jmh.spanner.server.port or SPANNER_PORT is specified. This allows running the mock server and JMH client in separate JVMs pinned to disjoint CPU cores.
  • Add MockSpannerServiceImpl.setRecordRequests(boolean) to bypass global synchronized (lock) contention and prevent unbounded retention of 20+ million request protobufs (~21.5 GB Old-Gen heap leak) during 20-minute benchmark runs.
  • Fix BenchmarkValidator so latency improvements (actual < baseline) do not fail validation, and include explicit units (us/op), allowed ceiling, percentage delta, and host SAR CPU telemetry (avg_busy, avg_steal, max_steal) in failure messages.

@sakthivelmanii
sakthivelmanii requested review from a team as code owners September 17, 2026 17:43
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@sakthivelmanii

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 refactors the benchmarking setup for the Spanner client by isolating the mock Spanner and monitoring gRPC servers into a separate JVM process (StandaloneBenchmarkServer) to prevent server threads and GC activity from interfering with the JMH benchmark client. Additionally, the benchmark validation logic was updated to allow improvements in latency to pass without throwing validation errors. Feedback on these changes includes: simplifying the validation check by removing a redundant Math.ceil call, clearing modified system properties in ReadBenchmark's tearDown to avoid test pollution, and adding try-catch error handling during StandaloneBenchmarkServer startup to prevent resource leaks on failure.

@sakthivelmanii
sakthivelmanii force-pushed the fix-spanner-benchmark-process-split branch 2 times, most recently from d1a15f6 to d333deb Compare September 17, 2026 18:45
…ing heap leak

- Add StandaloneBenchmarkServer and update ReadBenchmark to connect to an
  external gRPC mock server via SPANNER_PORT and MONITORING_PORT environment
  variables, throwing an IllegalStateException if SPANNER_PORT is missing.
  This allows running the mock server and JMH client in separate JVMs pinned
  to disjoint CPU cores.
- Add MockSpannerServiceImpl.setRecordRequests(boolean) to return early
  from maybeFreezeAndRecordRequest when disabled, bypassing global lock
  contention and preventing unbounded retention of 20+ million request
  protobufs (~21.5 GB Old-Gen heap leak) during 20-minute benchmark runs.
- Fix BenchmarkValidator so latency improvements (actual < baseline) do
  not fail validation.
@sakthivelmanii
sakthivelmanii force-pushed the fix-spanner-benchmark-process-split branch from d333deb to 574a011 Compare September 18, 2026 05:18
@sakthivelmanii sakthivelmanii added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 18, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 18, 2026
@sakthivelmanii
sakthivelmanii merged commit e1c9326 into main Sep 18, 2026
206 checks passed
@sakthivelmanii
sakthivelmanii deleted the fix-spanner-benchmark-process-split branch September 18, 2026 07:54
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