Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Quickperf for simple performance testing with JDBC #1619

Merged
merged 24 commits into from
Aug 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6a6907e
feat:Adding Quickperf for simple performance testing with JDBC
srozsnyai May 24, 2024
f776f5d
Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickper…
srozsnyai Jul 1, 2024
faad8f6
Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickper…
srozsnyai Jul 1, 2024
9cb1c2f
Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickper…
srozsnyai Jul 1, 2024
bcf1894
Update samples/quickperf/readme.md
srozsnyai Jul 1, 2024
2769587
Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickper…
srozsnyai Jul 1, 2024
4695030
Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickper…
srozsnyai Jul 1, 2024
c095e94
Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickper…
srozsnyai Jul 1, 2024
69b8dea
Updating based on review comments #1619
srozsnyai Jul 1, 2024
695246d
Merge branch 'quickperf' of https://github.com/srozsnyai/java-spanner…
srozsnyai Jul 1, 2024
4cec757
Updating based on review comments
srozsnyai Jul 1, 2024
fafc91e
Incorporating additional changes from review #1619
srozsnyai Jul 2, 2024
fda85f5
Split app into two classes to separate app driver and app following r…
srozsnyai Jul 2, 2024
60a355a
fixed compilation issues
srozsnyai Jul 2, 2024
10414f4
Update readme.md
srozsnyai Jul 16, 2024
7e068f0
Update readme.md
srozsnyai Jul 16, 2024
2080195
Update QuickPerf.java
srozsnyai Jul 16, 2024
9225c1b
Update ProgressTracker.java
srozsnyai Jul 16, 2024
228d59b
Merge branch 'main' into quickperf
olavloite Aug 20, 2024
83df96b
chore: add parent pom and run code formatter
olavloite Aug 20, 2024
b652ff8
chore: cleanup some warnings + simplify test setup
olavloite Aug 20, 2024
b129835
test: add test runner for quickperf
olavloite Aug 20, 2024
f1b6b1a
chore: remove some more warnings
olavloite Aug 20, 2024
71b6547
fix: include empty test file
olavloite Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updating based on review comments #1619
srozsnyai committed Jul 1, 2024
commit 69b8dea6a32ba8b3be3b187dbfea9f3105821882
14 changes: 7 additions & 7 deletions samples/quickperf/exampleconfigs/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"project": "xxxx",
"instance": "xxx",
"database": "xxx",
"threads": 1,
"iterations": 100,
"query": "SELECT 1",
"writeMetricToFile": false
"project": "xxxx",
"instance": "xxx",
"database": "xxx",
"threads": 1,
"iterations": 100,
"query": "SELECT 1",
"writeMetricToFile": false
}
33 changes: 16 additions & 17 deletions samples/quickperf/pom.xml
Original file line number Diff line number Diff line change
@@ -22,32 +22,19 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.34.0</version>
<version>26.38.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.datafaker</groupId>
<artifactId>datafaker</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.34.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
@@ -60,8 +47,6 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner-jdbc</artifactId>
<!-- <version>2.11.5</version> -->
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@@ -84,14 +69,28 @@
<groupId>org.springframework.boot</groupId>
olavloite marked this conversation as resolved.
Show resolved Hide resolved
<artifactId>spring-boot</artifactId>
<version>3.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that you can safely remove this whole pluginManagement section.

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 plugin management

parent pom) -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<mainClass>com.google.cloud.jdbc.quickperf.QuickPerf</mainClass>
</configuration>
</plugin>
<!-- clean lifecycle, see
https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
16 changes: 15 additions & 1 deletion samples/quickperf/readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# Introduction

QuickPerf is a simple utility that uses JDBC to perform load testing on individual statements (such as queries and DML) against Spanner. It provides a rapid assessment of expected end-to-end latencies for specific statements, aiding in the performance tuning of schemas, indexes, and more. The tool includes random data generators to quickly fill a given schema with dummy data, respecting foreign-key relationships and interleaved tables.

QuickPerf is not designed to replace comprehensive test suites like JMeter. Instead, it serves as a quick alternative for gaining performance insights or populating schemas.

**Key Features**:
* Multi-threading to simulate concurrency
* Query parameterization with random value generators (String, Integer, Timestamp)
* Sampling of records for seeding foreign-key relationships or testing against a specific subset of data
* Batch mode support
* Automatic statement and transaction tagging


# Installation on Ubuntu
olavloite marked this conversation as resolved.
Show resolved Hide resolved
```
sudo apt-get install openjdk-8-jdk
sudo apt install maven
```

## Authentification
It is recommended to use a service accounts otherwise larger scale tests will run into quota limitations
It is recommended to use a service account, otherwise larger scale tests will run into quota limitations

Set active auth to service account:
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* 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.
@@ -19,12 +19,12 @@
import java.util.List;

public class ProgressTracker extends Thread {
private static int SLEEP_TIME_INIT = 2000;
private static int SLEEP_TIME_POLL = 200;
private static final int SLEEP_TIME_INIT = 2000;
private static final int SLEEP_TIME_POLL = 200;

private List<QuickPerf> threadList;
private final List<QuickPerf> threadList;

private int maxIt;
private final int maxIt;
private int currentIt = 0;

public ProgressTracker(List<QuickPerf> threadList, int maxIt) {
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* 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.
@@ -209,13 +209,8 @@ public void run() {
Connection connection = DriverManager.getConnection(connectionUrl);

// determin database dialect to set right tagging syntax
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:

Suggested change
// determin database dialect to set right tagging syntax
// determine database dialect to set right tagging syntax

boolean isGoogleSQL;
if (connection.unwrap(CloudSpannerJdbcConnection.class).getDialect()
.equals(Dialect.GOOGLE_STANDARD_SQL)) {
isGoogleSQL = true;
} else {
isGoogleSQL = false;
}
boolean isGoogleSQL = connection.unwrap(CloudSpannerJdbcConnection.class).getDialect()
.equals(Dialect.GOOGLE_STANDARD_SQL);

connection.setAutoCommit(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Move this to inside the if statement that checks whether the benchmark uses DML


@@ -463,7 +458,7 @@ private int replaceInt(String value) {
private Double replaceDouble(String value) {
Faker f = new Faker();

return Double.valueOf(value.replaceFirst("#i", String.valueOf(f.number().randomDouble(2, 0,
return Double.valueOf(value.replaceFirst("#d", String.valueOf(f.number().randomDouble(2, 0,
999999999))));
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.jdbc.quickperf.config;
olavloite marked this conversation as resolved.
Show resolved Hide resolved

import java.util.List;
@@ -28,9 +44,6 @@ public String paramsToString() {
return retVal;
}

// Getters and setters


public int getBatchSize() {
return this.batchSize;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.jdbc.quickperf.config;


Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
/*
* 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.jdbc.quickperf.config;


public class QueryParam {
private int order;
private String value;

// Getters and setters

public int getOrder() {
return order;
}