-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into allow-ddl-in-autocommit-off
- Loading branch information
Showing
64 changed files
with
3,122 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Latency Tests | ||
|
||
This directory contains a utility to compare latencies of different public methods supported by the Java Client Library. | ||
The tests use simple statements that operate on a single row at a time. | ||
|
||
The goal is that addition of new features should not add any latency. | ||
|
||
## Setup Test Database | ||
|
||
All tests in this directory use a database with a single table. Follow these steps to create a | ||
database that you can use for these tests: | ||
|
||
1. Set up some environment variables. These will be used by all following steps. | ||
```shell | ||
export SPANNER_CLIENT_BENCHMARK_GOOGLE_CLOUD_PROJECT=my-project | ||
export SPANNER_CLIENT_BENCHMARK_SPANNER_INSTANCE=my-instance | ||
export SPANNER_CLIENT_BENCHMARK_SPANNER_DATABASE=my-database | ||
``` | ||
|
||
2. Create the Cloud Spanner database if it does not already exist using Pantheon UI. | ||
3. Create the test table in the Cloud Spanner database. The tests assume the below DDL for the table. | ||
|
||
```shell | ||
CREATE TABLE FOO ( id INT64 NOT NULL, BAZ INT64, BAR INT64, ) PRIMARY KEY(id); | ||
``` | ||
4. Generate some random test data that can be used for the benchmarking. This can be done | ||
by using the script `bulkInsertTestData` in class `BenchmarkingUtilityScripts` to bulk | ||
load 1000000 rows into this table. A large table makes sure that the queries are well | ||
randomised and there is no hot-spotting. | ||
|
||
## Running | ||
|
||
The benchmark application includes Java Client as a dependency. Modify the dependency | ||
version in `pom.xml` file if you wish to benchmark a different version of Java Client. | ||
|
||
|
||
* The below command uses only 1 thread and 1000 operations. So the total load would | ||
be 1000 read operations. The test also uses multiplexed sessions. | ||
```shell | ||
mvn clean compile exec:java -Dexec.args="--clients=1 --operations=1000 --multiplexed=true" | ||
``` | ||
|
||
* The below command uses 10 threads, so at any point in time there would be roughly | ||
10 concurrent requests. The total load of the benchmark would be 50000 read operations. | ||
```shell | ||
mvn clean compile exec:java -Dexec.args="--clients=10 --operations=5000 --multiplexed=true" | ||
``` | ||
|
||
* To run the same test without multiplexed sessions avoid passing `multiplexed` flag. This will | ||
make sure that tests uses regular sessions. | ||
```shell | ||
mvn clean compile exec:java -Dexec.args="--clients=10 --operations=5000" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<!-- | ||
Copyright 2023 Google LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-spanner-benchmark</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Google Cloud Spanner Benchmark</name> | ||
|
||
<parent> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-spanner-parent</artifactId> | ||
<version>6.65.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} --> | ||
</parent> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<junixsocket.version>2.9.1</junixsocket.version> | ||
<opentelemetry.version>1.36.0</opentelemetry.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-context</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud.opentelemetry</groupId> | ||
<artifactId>exporter-trace</artifactId> | ||
<version>0.25.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud.opentelemetry</groupId> | ||
<artifactId>exporter-metrics</artifactId> | ||
<version>0.25.2</version> | ||
</dependency> | ||
<!-- OpenTelemetry test dependencies --> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-metrics</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-trace</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-testing</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.re2j</groupId> | ||
<artifactId>re2j</artifactId> | ||
<version>1.7</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-bom</artifactId> | ||
<version>1.37.0</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-spanner</artifactId> | ||
<version>6.65.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>1.6.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto.value</groupId> | ||
<artifactId>auto-value-annotations</artifactId> | ||
<version>1.10.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.kohlschutter.junixsocket</groupId> | ||
<artifactId>junixsocket-core</artifactId> | ||
<version>${junixsocket.version}</version> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.kohlschutter.junixsocket</groupId> | ||
<artifactId>junixsocket-common</artifactId> | ||
<version>${junixsocket.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>1.7.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<configuration> | ||
<mainClass>com.google.cloud.spanner.benchmark.LatencyBenchmark</mainClass> | ||
<cleanupDaemonThreads>false</cleanupDaemonThreads> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.coveo</groupId> | ||
<artifactId>fmt-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>format</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
33 changes: 33 additions & 0 deletions
33
benchmarks/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.spanner; | ||
|
||
import com.google.api.core.InternalApi; | ||
|
||
/** | ||
* Simple helper class to get access to a package-private method in the {@link | ||
* com.google.cloud.spanner.SessionPoolOptions}. | ||
*/ | ||
@InternalApi | ||
public class SessionPoolOptionsHelper { | ||
|
||
// TODO: Remove when Builder.setUseMultiplexedSession(..) has been made public. | ||
public static SessionPoolOptions.Builder setUseMultiplexedSession( | ||
SessionPoolOptions.Builder sessionPoolOptionsBuilder, boolean useMultiplexedSession) { | ||
return sessionPoolOptionsBuilder.setUseMultiplexedSession(useMultiplexedSession); | ||
} | ||
} |
Oops, something went wrong.