Skip to content

Conversation

@arpan14
Copy link
Contributor

@arpan14 arpan14 commented Nov 23, 2023

  • Adding a benchmark (along with usual considerations) for measuring the latencies of some Java Client APIs. For any new feature, we usually first define the baseline by running benchmarks (without the feature).
  • Adding few utility methods to measure the p99/p95/p50 latencies.
  • Added benchmarking best-practices to avoid hotspot (by randomising keys), avoid cold start, etc.

@arpan14 arpan14 requested a review from a team as a code owner November 23, 2023 05:31
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Nov 23, 2023
@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Nov 23, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Nov 23, 2023
@gcf-owl-bot gcf-owl-bot bot requested a review from a team as a code owner November 23, 2023 07:38
@arpan14 arpan14 requested a review from olavloite February 27, 2024 10:07
public class BenchmarkingUtilityTest {

@ClassRule
public static IntegrationTestEnv env = new IntegrationTestEnv();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment on lines 187 to 193
* <p>Some read requests will be long-running and will cause session leaks. Such sessions will be
* removed by the session maintenance background task if SessionPool Option
* ActionOnInactiveTransaction is set as WARN_AND_CLOSE.
*
* <p>Some write requests will be long-running. The test asserts that no sessions are removed by
* the session maintenance background task with SessionPool Option ActionOnInactiveTransaction set
* as WARN_AND_CLOSE. This is because PDML writes are expected to be long-running.
Copy link
Collaborator

Choose a reason for hiding this comment

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

copy-paste error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, removed.

final BenchmarkState server, int numberOfOperations) {
List<Duration> results = new ArrayList<>(numberOfOperations);
// Execute one update to make sure everything has been warmed up.
executeUpdate(server);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this also call executeWarmup, so the number of warmup queries is respected for updates as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, added this.

* <p>Table schema used here: CREATE TABLE FOO ( id INT64 NOT NULL, BAZ INT64, BAR INT64, )
* PRIMARY KEY(id);
*/
@Test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want this as an actual test that is executed during (nightly?) builds? If so, it should verify that the test actually succeeds by adding at least one assertion.

Or would it make more sense to move this method to the actual benchmark class, so it can more easily be executed together with a benchmark?

Copy link
Contributor Author

@arpan14 arpan14 Mar 1, 2024

Choose a reason for hiding this comment

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

I had annotated BenchmarkingUtilityTest with @Category(SlowTest.class). This will make sure its excluded from our pre-submits and nightly tests. Note that the data loading utility is a one time activity and does not need to be executed repeatedly along with the benchmarks. Hence, I think it will be better to leave this as separate standalone class.

  • I have now moved the latency reporting utility methods (printResults, percentile, etc.) to a new class AbstractLatencyBenchmark. Any benchmark that aims to report latencies can extend AbstractLatencyBenchmark and get this methods.
  • I am renaming this class to BenchmarkingUtilityScripts and it now only has the data loading functionality. Avoiding Test in the class name will ensure it does not qualify for any continuous tests.

arpan14 and others added 2 commits March 1, 2024 23:21
…nchmarkingUtilityTest.java

Co-authored-by: Knut Olav Løite <koloite@gmail.com>
@arpan14 arpan14 requested a review from olavloite March 1, 2024 18:14
Copy link
Collaborator

@olavloite olavloite left a comment

Choose a reason for hiding this comment

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

LGTM

*
* <p>CREATE TABLE FOO ( id INT64 NOT NULL, BAZ INT64, BAR INT64, ) PRIMARY KEY(id);
*
* <p>Below are a few considerations here: 1. We use all default options for this test because that
Copy link
Collaborator

Choose a reason for hiding this comment

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

super-nit (feel free to leave as is): Use <ol> and <li> tags to create an actual ordered (numbered) list.

@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 2, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 2, 2024
@arpan14 arpan14 added the automerge Merge the pull request once unit tests and other checks pass. label Mar 2, 2024
@gcf-merge-on-green gcf-merge-on-green bot merged commit 9a8cce8 into googleapis:main Mar 2, 2024
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Mar 2, 2024
@arpan14 arpan14 deleted the latency-benchmark-utils branch March 2, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants