Skip to content

Commit 4a23303

Browse files
committed
Merge branch 'scchatur/PerfTest' into imabhichow/perf-python
2 parents 4537477 + b10839b commit 4a23303

24 files changed

+1505
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# AWS Database Encryption SDK Performance Test
2+
3+
This project contains tests to benchmark the old v2 and the new v3 AWS Database Encryption SDK for DynamoDb in Java.
4+
5+
## Benchmarking
6+
### Prerequisites
7+
You'd need the appropriate security credentials to run the Kms Key based tests. Also, build all the Gazelle dependecies and deploy to maven local.
8+
The idea of perf test is to run everything from local, before the changes make it to maven central.
9+
10+
1. `ada credentials update --account=370957321024 --role=Admin --once`
11+
2. `cd ../../../../DynamoDbEncryption && make build_java mvn_local_deploy_dependencies mvn_local_deploy`
12+
13+
In case of any failures, look into the `README` for `DynamoDbEncryption`.
14+
15+
### Gradle Jmh
16+
17+
`` ./gradlew jmh``
18+
19+
This will generate a report on console as well as in `build/results/jmh/results.txt` with the following format:
20+
```
21+
Benchmark (plainTextFile) Mode Cnt Score Error Units
22+
s.a.c.p.i.v2.AesKeyProviderTest.decrypt single_attribute.json avgt 3 2.428 ± 1.484 ms/op
23+
s.a.c.p.i.v2.AesKeyProviderTest.encrypt single_attribute.json avgt 3 2.691 ± 2.510 ms/op
24+
s.a.c.p.i.v3.RawAesKeyringTest.decrypt single_attribute.json avgt 3 56.868 ± 14.556 ms/op
25+
s.a.c.p.i.v3.RawAesKeyringTest.encrypt single_attribute.json avgt 3 42.814 ± 1.302 ms/op
26+
...
27+
```
28+
29+
Size report will also be generated in the same directory, `build/results/size.txt` with the following format:
30+
31+
```
32+
AesKeyProviderTest_decrypt_jmhTest 205152 274001 68849
33+
AesKeyProviderTest_encrypt_jmhTest 205152 274001 68849
34+
AwsKmsKeyProviderTest_decrypt_jmhTest 205152 274349 69197
35+
AwsKmsKeyProviderTest_encrypt_jmhTest 205152 274349 69197
36+
...
37+
```
38+
39+
where the columns are `OperationName OriginalSize EncryptedSize Diff`
40+
41+
### IDE (or Main Class)
42+
1. Run the `main()` method in the TestBase class, or you can also run individual tests by executing the `main()` method in the respective classes.
43+
2. This serves the purpose of quickly debugging benchmarking/jmh issues.
44+
45+
## Profiling (Flamegraph) in IntelliJ
46+
1. Use the main method in each Test class and `Run with Profiler`.
47+
2. The graph would show the stack and the relative time taken by each of the method call
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import java.net.URI
2+
import javax.annotation.Nullable
3+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
4+
import org.gradle.api.tasks.testing.logging.TestLogEvent
5+
import java.awt.SystemColor.info
6+
import java.nio.file.Files.delete
7+
8+
plugins {
9+
`java`
10+
`java-library`
11+
id("me.champeau.jmh") version "0.7.0"
12+
}
13+
14+
group = "software.amazon.cryptography"
15+
version = "1.0-SNAPSHOT"
16+
description = "DynamoDbEncryptionPerformanceTest"
17+
18+
java {
19+
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
20+
sourceSets["main"].java {
21+
srcDir("src/main/java")
22+
}
23+
sourceSets["test"].java {
24+
srcDir("src/test/java")
25+
}
26+
}
27+
28+
sourceSets {
29+
this.jmh {
30+
java.setSrcDirs(mutableListOf("src/main/java"))
31+
}
32+
}
33+
34+
var caUrl: URI? = null
35+
@Nullable
36+
val caUrlStr: String? = System.getenv("CODEARTIFACT_URL_JAVA_CONVERSION")
37+
if (!caUrlStr.isNullOrBlank()) {
38+
caUrl = URI.create(caUrlStr)
39+
}
40+
41+
var caPassword: String? = null
42+
@Nullable
43+
val caPasswordString: String? = System.getenv("CODEARTIFACT_AUTH_TOKEN")
44+
if (!caPasswordString.isNullOrBlank()) {
45+
caPassword = caPasswordString
46+
}
47+
48+
repositories {
49+
mavenCentral()
50+
mavenLocal()
51+
52+
// While commented out, this project will not pull from CodeArtifact, you must build and deploy dependencies locally
53+
//
54+
// maven {
55+
// name = "CodeArtifact"
56+
// url = URI.create("https://avp10745-648638458147.d.codeartifact.us-west-2.amazonaws.com/maven/AVP-10745/")
57+
// credentials {
58+
// username = "aws"
59+
// password = System.getenv("CODEARTIFACT_AUTH_TOKEN")
60+
// }
61+
//}
62+
}
63+
64+
dependencies {
65+
implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:1.0-SNAPSHOT")
66+
implementation("software.amazon.cryptography:AwsCryptographicMaterialProviders:1.0-SNAPSHOT")
67+
68+
implementation(platform("software.amazon.awssdk:bom:2.19.1"))
69+
implementation("software.amazon.awssdk:dynamodb:2.20.64")
70+
implementation("software.amazon.awssdk:dynamodb-enhanced")
71+
implementation("com.amazonaws:aws-java-sdk-dynamodb:1.12.409")
72+
implementation("software.amazon.awssdk:kms")
73+
74+
implementation("org.openjdk.jmh:jmh-core:1.36")
75+
implementation("org.openjdk.jmh:jmh-generator-annprocess:1.36")
76+
annotationProcessor ("org.openjdk.jmh:jmh-generator-annprocess:1.36")
77+
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.0")
78+
implementation("com.univocity:univocity-parsers:2.9.1")
79+
implementation("javax.xml.bind:jaxb-api:2.3.1")
80+
implementation("org.apache.commons:commons-lang3:3.8.1")
81+
82+
// https://mvnrepository.com/artifact/org.testng/testng
83+
testImplementation("org.testng:testng:7.5")
84+
}
85+
86+
tasks.withType<JavaCompile>() {
87+
options.encoding = "UTF-8"
88+
}
89+
90+
gradle.taskGraph.whenReady {
91+
delete {
92+
file("build/results/").deleteRecursively()
93+
}
94+
}
95+
96+
tasks.test {
97+
useTestNG()
98+
99+
// This will show System.out.println statements
100+
testLogging.showStandardStreams = true
101+
102+
testLogging {
103+
lifecycle {
104+
events = mutableSetOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED)
105+
exceptionFormat = TestExceptionFormat.FULL
106+
showExceptions = true
107+
showCauses = true
108+
showStackTraces = true
109+
showStandardStreams = true
110+
}
111+
info.events = lifecycle.events
112+
info.exceptionFormat = lifecycle.exceptionFormat
113+
}
114+
115+
// See https://github.com/gradle/kotlin-dsl/issues/836
116+
addTestListener(object : TestListener {
117+
override fun beforeSuite(suite: TestDescriptor) {}
118+
override fun beforeTest(testDescriptor: TestDescriptor) {}
119+
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
120+
121+
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
122+
if (suite.parent == null) { // root suite
123+
logger.lifecycle("----")
124+
logger.lifecycle("Test result: ${result.resultType}")
125+
logger.lifecycle("Test summary: ${result.testCount} tests, " +
126+
"${result.successfulTestCount} succeeded, " +
127+
"${result.failedTestCount} failed, " +
128+
"${result.skippedTestCount} skipped")
129+
}
130+
}
131+
})
132+
}
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)