From 62580b1272921713ad1bddf55f7b6543f9b6c5fd Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 10:59:23 -0800 Subject: [PATCH 01/12] chore: add java benchmark tests --- .../.gradle/8.14/checksums/checksums.lock | Bin 0 -> 17 bytes .../.gradle/8.14/checksums/sha1-checksums.bin | Bin 0 -> 18659 bytes .../executionHistory/executionHistory.bin | Bin 0 -> 19986 bytes .../executionHistory/executionHistory.lock | Bin 0 -> 17 bytes .../.gradle/8.14/fileChanges/last-build.bin | Bin 0 -> 1 bytes .../.gradle/8.14/fileHashes/fileHashes.bin | Bin 0 -> 19147 bytes .../.gradle/8.14/fileHashes/fileHashes.lock | Bin 0 -> 17 bytes .../java/.gradle/8.14/gc.properties | 0 .../buildOutputCleanup.lock | Bin 0 -> 17 bytes .../buildOutputCleanup/cache.properties | 2 + .../buildOutputCleanup/outputFiles.bin | Bin 0 -> 18767 bytes .../benchmarks/java/.gradle/file-system.probe | Bin 0 -> 8 bytes .../java/.gradle/vcs-1/gc.properties | 0 .../benchmarks/java/README.md | 218 ++++++++ .../benchmarks/java/build.gradle.kts | 89 ++++ .../java/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43764 bytes .../gradle/wrapper/gradle-wrapper.properties | 7 + .../benchmarks/java/gradlew | 251 +++++++++ .../benchmarks/java/gradlew.bat | 94 ++++ .../benchmarks/java/settings.gradle.kts | 1 + .../dbesdk/benchmark/BenchmarkResult.java | 137 +++++ .../dbesdk/benchmark/DBESDKBenchmark.java | 488 ++++++++++++++++++ .../amazon/dbesdk/benchmark/KeyringSetup.java | 65 +++ .../com/amazon/dbesdk/benchmark/Program.java | 223 ++++++++ .../amazon/dbesdk/benchmark/TestConfig.java | 195 +++++++ .../com/amazon/dbesdk/benchmark/Utils.java | 207 ++++++++ 26 files changed, 1977 insertions(+) create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/checksums.lock create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/sha1-checksums.bin create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.bin create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.lock create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileChanges/last-build.bin create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.bin create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.lock create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/gc.properties create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/buildOutputCleanup.lock create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/outputFiles.bin create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/file-system.probe create mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/vcs-1/gc.properties create mode 100644 db-esdk-performance-testing/benchmarks/java/README.md create mode 100644 db-esdk-performance-testing/benchmarks/java/build.gradle.kts create mode 100644 db-esdk-performance-testing/benchmarks/java/gradle/wrapper/gradle-wrapper.jar create mode 100644 db-esdk-performance-testing/benchmarks/java/gradle/wrapper/gradle-wrapper.properties create mode 100755 db-esdk-performance-testing/benchmarks/java/gradlew create mode 100644 db-esdk-performance-testing/benchmarks/java/gradlew.bat create mode 100644 db-esdk-performance-testing/benchmarks/java/settings.gradle.kts create mode 100644 db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java create mode 100644 db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java create mode 100644 db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java create mode 100644 db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java create mode 100644 db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java create mode 100644 db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/checksums.lock b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/checksums.lock new file mode 100644 index 0000000000000000000000000000000000000000..3749592ae527b5a05000497cd77e570131d35c3a GIT binary patch literal 17 UcmZRsVwpUpcQxx01_)pU04tsYj{pDw literal 0 HcmV?d00001 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/sha1-checksums.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/sha1-checksums.bin new file mode 100644 index 0000000000000000000000000000000000000000..ca074afd2955fd901701ceef698a737ea816e2f1 GIT binary patch literal 18659 zcmeI(JxGE<9LMof$>;^LD6l13+6<&1X(%Z&E0+)r3a6G_f*@3aq9J%7m)4$g4~l4U z5J#INa8YPATuK6o-rVZ0=XnrmZi(-~J@@B#{Ga1K>%+4kgxmFH4$&Gzt&$1>1Q0*~ z0R#|0009ILKmY**5I_I{1Q0*~0R;YwKvZ6&+qjI|V^>9AN(gVSEF4GGkT+J?x-+(y z=B)1r;bHx(o~~?|dCJQ7*Jelh3(bg`Ut77g%6#3}UYZyq%Dk`T7@hsVzob-E+}mXOOtdspzd81s+%KH`~9E&mdqPwcLg tf4ZLh#yo0SHsI0st-TB?##1!pJ8?z)@kLBqycFjW%QYA?&1nV0NjXLpA8 z-tL;5JhZ4JB#I)6|Db}PpdKWG7txFLQVY_kP?dlPB8Y_wqN4WgZk9y!ASfvE9hjNN z%$xW7{XX;CxonD%CjHgaMy9u~riU0o00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$## zAn>^eq*WoaYsEAz3snYl%Y?LisRmk$J%4j(&haC)+iO?X|39do)%B&ddpJS>0uX=z z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV= z5P$##An+*&La{Gnw!i>~MN+T0Cfra8llg^ca_qR3fmbA8m7iBpzLw715Rt?ls^ zr#+GAYiqNk@wnqSi71OD_2fx?pVt3`pU8^WvzwjYqy|&<60`8j` zus2KF;>&xBdGgw08wUf{cWGZ zy-WL)|l+!2-?uj-}=rmC1(c_dcKJX~AZOWJ0=ye$!G9W%HEhR3KWSQUGqA(<(Wl z|Fz*(&&v~&|NJs>fBp6S9kJnR?vE!z;jw`GibA?fRBO2NDb_HZBhkm5l?TtKC$B%a z`FG#VMWbhHr99Wd!=m~@saEkq`wwtx9=UVdLK@OHT4bu F^M7uRT_*ql literal 0 HcmV?d00001 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.lock b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.lock new file mode 100644 index 0000000000000000000000000000000000000000..81059cc752d87e9658f2ad8a408a660cf1400e67 GIT binary patch literal 17 UcmZQRp8Fzs$@>W!3=qH!06oqG(EtDd literal 0 HcmV?d00001 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileChanges/last-build.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileChanges/last-build.bin new file mode 100644 index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d GIT binary patch literal 1 IcmZPo000310RR91 literal 0 HcmV?d00001 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.bin new file mode 100644 index 0000000000000000000000000000000000000000..16ad5901b7af88f78680b96e8aca8864cb2bad22 GIT binary patch literal 19147 zcmeI(ZAcSg00;1A*{r7GD6C0Jt|k`)nJ&Y`D z#lpnDkdO#pcH+l``?XE#G+Er~lsx+Xfum!pJ)vEj%H^s=n!j_-lb<8*AudmiqPfeJ zZxVOUsQ7hW(_9>&U(d9pH}Kbc(R`gH=W6-4$vXb}SenP2@O2J1<~jMip62m3W5A8p z&}@F49GYvoPW6O*eXQj3I-2KPzBvB5^k6ratA=QvTYRsequ;WMUw;kF3v+8fy0_27 z^Vb__ZZwTI_Qq{w_`Hec^hk&(g*%5m1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U< z00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafK;Yj9M6$Qp#%}V3O=|S|5ELYO zQNO7`seHK85X!#k&Wug;C9o&i;d7qdg?l!v>QT*ni{q{C%|!ZOZ4CQP{$j&tu|V!m z3ma`G=Mpr_=TOkwAo=yv?Dy!ieQQSQ?2MZgK`Z} zR?YIpN_mo7*eJUco29=yoIJ<;QhUksJC`@elj!%thB|pN)Fdh0|0Pj#eecYUT^H05IPJn*aa+ literal 0 HcmV?d00001 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/gc.properties b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/gc.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000000000000000000000000000000000000..72e392186a6aae9a45f81a7c05a80b7a423d1ca2 GIT binary patch literal 17 UcmZSHdQ9T$fp4B(3=kj$06qr<=Kufz literal 0 HcmV?d00001 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties b/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000000..e5ee10e4d5 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Jan 21 10:54:09 PST 2026 +gradle.version=8.14 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/outputFiles.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000000000000000000000000000000000000..db5637287f664a6c3711624cc7bc2ed4ce640027 GIT binary patch literal 18767 zcmeI%Pbfoi0KoCzl$JlSi<)TVrlw3p$qFg9!<0qIO|iocQnLIhkwoL>pca=&E)J5W zWJ;zMmlX%M*@%&~(#l0_-tX6v+fLH=)$hGu-}ig3_xoI5mk>t7r#wXNsK`y3A%Fk^ z2q1s}0tg_000IagfB*srAbFBYx$cvSZ%Uq>G{1M_mdUiFjE#IxP*sg>(TR1Z5s)!p0POWF5S zkDk2++k=C4**jEE7rvV&KMs0jcd9N77kAgQsVCW2RPVc8+HF49CuBcWePDmp?Qn%} zWRIvmWLj^E&eXKZ?o-{hI2TJUIKx`ESydlT97m4sw@T#txauDF#$&1>ZIwN(`g9=X zziO-U$@iF5S63l)Q`$Yw2q1s}0tg_000IagfB*srAb Path to test configuration file (default: ../config/test-scenarios.yaml) + -h,--help Show this help message + -o,--output Path to output results file (default: ../results/raw-data/java_results.json) + -q,--quick Run quick test with reduced iterations +``` + +## Output Format + +Results are saved to JSON format matching the Go implementation: + +```json +{ + "metadata": { + "language": "java", + "timestamp": "2025-01-21 10:50:00", + "java_version": "11.0.16", + "cpu_count": 8, + "total_memory_gb": 16.0, + "total_tests": 22 + }, + "results": [ + { + "test_name": "throughput", + "language": "java", + "data_size": 1024, + "concurrency": 1, + "put_latency_ms": 1.2, + "get_latency_ms": 1.1, + "end_to_end_latency_ms": 2.3, + "ops_per_second": 426.4, + "bytes_per_second": 436641.2, + "peak_memory_mb": 0, + "memory_efficiency_ratio": 0, + "p50_latency": 1.8, + "p95_latency": 1.81, + "p99_latency": 1.82, + "timestamp": "2025-01-21 10:45:30", + "java_version": "11.0.16", + "cpu_count": 8, + "total_memory_gb": 16.0 + } + ] +} +``` + +## Architecture + +The Java implementation mirrors the Go benchmark architecture: + +### Core Components + +- **`Program.java`**: Main entry point with CLI argument parsing +- **`DBESDKBenchmark.java`**: Main benchmark orchestration and execution +- **`TestConfig.java`**: YAML configuration parsing and management +- **`BenchmarkResult.java`**: Results data structure matching Go output format +- **`KeyringSetup.java`**: Keyring initialization (Raw AES keyring) +- **`Utils.java`**: Utility functions for statistics, memory monitoring, and formatting + +### Test Implementation + +- **Throughput Tests**: Measure `EncryptItem` and `DecryptItem` operations separately +- **Memory Tests**: Continuous heap monitoring during operations using JVM MemoryMXBean +- **Concurrency Tests**: ExecutorService-based multi-threaded testing + +### DynamoDB Item Structure + +The benchmark tests encryption of DynamoDB items with this structure: + +```java +{ + "partition_key": "benchmark-test", // SIGN_ONLY + "sort_key": "0", // SIGN_ONLY + "attribute1": { // ENCRYPT_AND_SIGN + "data": + }, + "attribute2": "sign me!", // SIGN_ONLY + ":attribute3": "ignore me!" // DO_NOTHING (prefix excludes from encryption) +} +``` + +## Dependencies + +- **AWS Database Encryption SDK for DynamoDB**: Core encryption functionality +- **AWS Cryptographic Material Providers Library**: Keyring management +- **AWS SDK for Java v2**: DynamoDB types and utilities +- **SnakeYAML**: Configuration file parsing +- **Jackson**: JSON output formatting +- **Apache Commons CLI**: Command line argument parsing + +## System Requirements + +- **Java 11+**: Minimum supported version +- **Gradle**: Build system (wrapper included) +- **Memory**: At least 2GB heap recommended for large data size tests +- **CPU**: Multi-core recommended for concurrency tests + +## Comparison with Go Implementation + +The Java implementation provides identical functionality to the Go version: + +- **Same test types**: throughput, memory, concurrency +- **Same data sizes**: 1KB to 100MB range +- **Same configuration format**: YAML with quick mode support +- **Same output format**: JSON with matching field names and structure +- **Same keyring setup**: Raw AES-256 keyring with random key generation +- **Same item structure**: Identical DynamoDB attribute encryption policies + +## Performance Notes + +- **JVM Warmup**: The benchmark includes warmup iterations to account for JIT compilation +- **Memory Measurement**: Uses JVM MemoryMXBean for accurate heap usage tracking +- **Garbage Collection**: Forces GC between memory test iterations for consistent measurements +- **Concurrency**: Uses ExecutorService thread pools for controlled concurrent testing + +## Examples + +```bash +# Quick benchmark with default settings +./gradlew run --args="--quick" + +# Full benchmark with custom configuration +./gradlew run --args="-c /path/to/custom-config.yaml -o /path/to/results.json" + +# Run only specific test types (modify config file) +# Edit config.yaml to set quick_config.test_types: ["throughput"] +./gradlew run --args="--quick" + +# Build standalone JAR and run +./gradlew fatJar +java -Xmx4g -jar build/libs/db-esdk-benchmark-java-1.0.0-all.jar --quick diff --git a/db-esdk-performance-testing/benchmarks/java/build.gradle.kts b/db-esdk-performance-testing/benchmarks/java/build.gradle.kts new file mode 100644 index 0000000000..1aa58952b6 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/build.gradle.kts @@ -0,0 +1,89 @@ +import java.io.File +import java.io.FileInputStream +import java.util.Properties + +plugins { + java + application +} + +// Load properties from the main project +var props = Properties().apply { + load(FileInputStream(File(rootProject.rootDir, "../../../project.properties"))) +} + +group = "com.amazon.dbesdk.benchmark" +version = "1.0.0" +description = "DB-ESDK Performance Benchmark for Java" + +var mplVersion = props.getProperty("mplDependencyJavaVersion") +var dafnyRuntimeJavaVersion = props.getProperty("dafnyRuntimeJavaVersion") +var smithyDafnyJavaConversionVersion = props.getProperty("smithyDafnyJavaConversionVersion") + +java { + toolchain.languageVersion.set(JavaLanguageVersion.of(11)) +} + +application { + mainClass.set("com.amazon.dbesdk.benchmark.Program") +} + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + // Core DB-ESDK and cryptography dependencies + implementation("software.amazon.cryptography:aws-cryptographic-material-providers:${mplVersion}") + implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:${props.getProperty("projectJavaVersion")}") + + // AWS SDK v2 dependencies + implementation(platform("software.amazon.awssdk:bom:2.30.18")) + implementation("software.amazon.awssdk:dynamodb") + + // Configuration and JSON processing + implementation("org.yaml:snakeyaml:2.2") + implementation("com.fasterxml.jackson.core:jackson-databind:2.18.1") + + // Command line parsing + implementation("commons-cli:commons-cli:1.9.0") + + // Progress bar for visual feedback (optional) + implementation("me.tongfei:progressbar:0.10.1") + + // Testing dependencies + testImplementation("org.junit.jupiter:junit-jupiter:5.11.4") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4") +} + +tasks.test { + useJUnitPlatform() +} + +tasks.withType { + options.encoding = "UTF-8" +} + +// Create a fat JAR for easy execution +tasks.register("fatJar") { + archiveClassifier.set("all") + from(sourceSets.main.get().output) + dependsOn(configurations.runtimeClasspath) + from({ + configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) } + }) { + exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA") + } + manifest { + attributes["Main-Class"] = "com.amazon.dbesdk.benchmark.Program" + } +} + +// Run task configuration for easier command line usage +tasks.named("run") { + standardInput = System.`in` + if (project.hasProperty("args")) { + args = (project.property("args") as String).split(" ") + } +} diff --git a/db-esdk-performance-testing/benchmarks/java/gradle/wrapper/gradle-wrapper.jar b/db-esdk-performance-testing/benchmarks/java/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..1b33c55baabb587c669f562ae36f953de2481846 GIT binary patch literal 43764 zcma&OWmKeVvL#I6?i3D%6z=Zs?ofE*?rw#G$eqJB ziT4y8-Y@s9rkH0Tz>ll(^xkcTl)CY?rS&9VNd66Yc)g^6)JcWaY(5$5gt z8gr3SBXUTN;~cBgz&})qX%#!Fxom2Yau_`&8)+6aSN7YY+pS410rRUU*>J}qL0TnJ zRxt*7QeUqTh8j)Q&iavh<}L+$Jqz))<`IfKussVk%%Ah-Ti?Eo0hQH!rK%K=#EAw0 zwq@@~XNUXRnv8$;zv<6rCRJ6fPD^hfrh;0K?n z=p!u^3xOgWZ%f3+?+>H)9+w^$Tn1e;?UpVMJb!!;f)`6f&4|8mr+g)^@x>_rvnL0< zvD0Hu_N>$(Li7|Jgu0mRh&MV+<}`~Wi*+avM01E)Jtg=)-vViQKax!GeDc!xv$^mL z{#OVBA$U{(Zr8~Xm|cP@odkHC*1R8z6hcLY#N@3E-A8XEvpt066+3t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T7StYqK6_w`e+fjXq5L^y(0 z09QA6H4oFj59c2wR~{~>jUoDzDdKz}5#onYPJRwa`SUO)Pd4)?(ENBaFVLJr6Kvz= zhTtXqbx09C1z~~iZt;g^9_2nCZ{};-b4dQJbv8HsWHXPVg^@(*!@xycp#R?a|L!+` zY5w))JWV`Gls(=}shH0#r*;~>_+-P5Qc978+QUd>J%`fyn{*TsiG-dWMiJXNgwBaT zJ=wgYFt+1ACW)XwtNx)Q9tA2LPoB&DkL16P)ERWQlY4%Y`-5aM9mZ{eKPUgI!~J3Z zkMd5A_p&v?V-o-6TUa8BndiX?ooviev(DKw=*bBVOW|=zps9=Yl|-R5@yJe*BPzN}a0mUsLn{4LfjB_oxpv(mwq# zSY*%E{iB)sNvWfzg-B!R!|+x(Q|b@>{-~cFvdDHA{F2sFGA5QGiIWy#3?P2JIpPKg6ncI^)dvqe`_|N=8 '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/db-esdk-performance-testing/benchmarks/java/gradlew.bat b/db-esdk-performance-testing/benchmarks/java/gradlew.bat new file mode 100644 index 0000000000..5eed7ee845 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/db-esdk-performance-testing/benchmarks/java/settings.gradle.kts b/db-esdk-performance-testing/benchmarks/java/settings.gradle.kts new file mode 100644 index 0000000000..d1a150c7dc --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "db-esdk-benchmark-java" diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java new file mode 100644 index 0000000000..b062f86506 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java @@ -0,0 +1,137 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.amazon.dbesdk.benchmark; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represents the results of a single benchmark test. + * Fields match the Go implementation exactly for compatibility. + */ +public class BenchmarkResult { + @JsonProperty("test_name") + private String testName; + + @JsonProperty("language") + private String language; + + @JsonProperty("data_size") + private int dataSize; + + @JsonProperty("concurrency") + private int concurrency; + + @JsonProperty("put_latency_ms") + private double putLatencyMs; + + @JsonProperty("get_latency_ms") + private double getLatencyMs; + + @JsonProperty("end_to_end_latency_ms") + private double endToEndLatencyMs; + + @JsonProperty("ops_per_second") + private double opsPerSecond; + + @JsonProperty("bytes_per_second") + private double bytesPerSecond; + + @JsonProperty("peak_memory_mb") + private double peakMemoryMb; + + @JsonProperty("memory_efficiency_ratio") + private double memoryEfficiencyRatio; + + @JsonProperty("p50_latency") + private double p50Latency; + + @JsonProperty("p95_latency") + private double p95Latency; + + @JsonProperty("p99_latency") + private double p99Latency; + + @JsonProperty("timestamp") + private String timestamp; + + @JsonProperty("java_version") + private String javaVersion; + + @JsonProperty("cpu_count") + private int cpuCount; + + @JsonProperty("total_memory_gb") + private double totalMemoryGb; + + // Constructors + public BenchmarkResult() {} + + public BenchmarkResult(String testName, String language, int dataSize, int concurrency) { + this.testName = testName; + this.language = language; + this.dataSize = dataSize; + this.concurrency = concurrency; + } + + // Getters and Setters + public String getTestName() { return testName; } + public void setTestName(String testName) { this.testName = testName; } + + public String getLanguage() { return language; } + public void setLanguage(String language) { this.language = language; } + + public int getDataSize() { return dataSize; } + public void setDataSize(int dataSize) { this.dataSize = dataSize; } + + public int getConcurrency() { return concurrency; } + public void setConcurrency(int concurrency) { this.concurrency = concurrency; } + + public double getPutLatencyMs() { return putLatencyMs; } + public void setPutLatencyMs(double putLatencyMs) { this.putLatencyMs = putLatencyMs; } + + public double getGetLatencyMs() { return getLatencyMs; } + public void setGetLatencyMs(double getLatencyMs) { this.getLatencyMs = getLatencyMs; } + + public double getEndToEndLatencyMs() { return endToEndLatencyMs; } + public void setEndToEndLatencyMs(double endToEndLatencyMs) { this.endToEndLatencyMs = endToEndLatencyMs; } + + public double getOpsPerSecond() { return opsPerSecond; } + public void setOpsPerSecond(double opsPerSecond) { this.opsPerSecond = opsPerSecond; } + + public double getBytesPerSecond() { return bytesPerSecond; } + public void setBytesPerSecond(double bytesPerSecond) { this.bytesPerSecond = bytesPerSecond; } + + public double getPeakMemoryMb() { return peakMemoryMb; } + public void setPeakMemoryMb(double peakMemoryMb) { this.peakMemoryMb = peakMemoryMb; } + + public double getMemoryEfficiencyRatio() { return memoryEfficiencyRatio; } + public void setMemoryEfficiencyRatio(double memoryEfficiencyRatio) { this.memoryEfficiencyRatio = memoryEfficiencyRatio; } + + public double getP50Latency() { return p50Latency; } + public void setP50Latency(double p50Latency) { this.p50Latency = p50Latency; } + + public double getP95Latency() { return p95Latency; } + public void setP95Latency(double p95Latency) { this.p95Latency = p95Latency; } + + public double getP99Latency() { return p99Latency; } + public void setP99Latency(double p99Latency) { this.p99Latency = p99Latency; } + + public String getTimestamp() { return timestamp; } + public void setTimestamp(String timestamp) { this.timestamp = timestamp; } + + public String getJavaVersion() { return javaVersion; } + public void setJavaVersion(String javaVersion) { this.javaVersion = javaVersion; } + + public int getCpuCount() { return cpuCount; } + public void setCpuCount(int cpuCount) { this.cpuCount = cpuCount; } + + public double getTotalMemoryGb() { return totalMemoryGb; } + public void setTotalMemoryGb(double totalMemoryGb) { this.totalMemoryGb = totalMemoryGb; } + + @Override + public String toString() { + return String.format("BenchmarkResult{testName='%s', dataSize=%d, concurrency=%d, opsPerSecond=%.2f}", + testName, dataSize, concurrency, opsPerSecond); + } +} diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java new file mode 100644 index 0000000000..1153de9f51 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java @@ -0,0 +1,488 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.amazon.dbesdk.benchmark; + +import com.fasterxml.jackson.databind.ObjectMapper; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.DynamoDbItemEncryptor; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DecryptItemInput; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DecryptItemOutput; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DynamoDbItemEncryptorConfig; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemInput; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemOutput; +import software.amazon.cryptography.dbencryptionsdk.structuredencryption.model.CryptoAction; +import software.amazon.cryptography.materialproviders.IKeyring; +import software.amazon.cryptography.materialproviders.model.DBEAlgorithmSuiteId; +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; + +import java.io.File; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryMXBean; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.concurrent.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Main DB-ESDK benchmark class that orchestrates performance testing. + */ +public class DBESDKBenchmark { + + private static final int MEMORY_TEST_ITERATIONS = 5; + private static final int SAMPLING_INTERVAL_MS = 1; + private static final int GC_SETTLE_TIME_MS = 5; + private static final int FINAL_SAMPLE_WAIT_MS = 2; + + private final TestConfig config; + private final IKeyring keyring; + private final DynamoDbItemEncryptor itemEncryptor; + private final List results; + private final int cpuCount; + private final double totalMemoryGb; + + /** + * Creates a new benchmark instance. + * + * @param configPath Path to the YAML configuration file + * @throws Exception if initialization fails + */ + public DBESDKBenchmark(String configPath) throws Exception { + this.config = TestConfig.loadConfig(configPath); + this.results = new ArrayList<>(); + this.cpuCount = Utils.getCpuCount(); + this.totalMemoryGb = Utils.getTotalMemoryGb(); + + // Initialize keyring + this.keyring = KeyringSetup.createKeyring(config.getKeyring()); + + // Initialize item encryptor + this.itemEncryptor = setupItemEncryptor(); + + System.out.printf("Initialized DB-ESDK Benchmark - CPU cores: %d, Memory: %.1f GB%n", + cpuCount, totalMemoryGb); + } + + /** + * Sets up the DynamoDB Item Encryptor with proper configuration. + */ + private DynamoDbItemEncryptor setupItemEncryptor() throws Exception { + // Define attribute actions (matching Go implementation) + Map attributeActions = new HashMap<>(); + attributeActions.put("partition_key", CryptoAction.SIGN_ONLY); + attributeActions.put("sort_key", CryptoAction.SIGN_ONLY); + attributeActions.put("attribute1", CryptoAction.ENCRYPT_AND_SIGN); + attributeActions.put("attribute2", CryptoAction.SIGN_ONLY); + attributeActions.put(":attribute3", CryptoAction.DO_NOTHING); + + String allowedUnsignedAttributePrefix = ":"; + DBEAlgorithmSuiteId algorithmSuiteId = DBEAlgorithmSuiteId.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384_SYMSIG_HMAC_SHA384; + + DynamoDbItemEncryptorConfig itemEncryptorConfig = DynamoDbItemEncryptorConfig.builder() + .logicalTableName(config.getTableName()) + .partitionKeyName("partition_key") + .sortKeyName("sort_key") + .attributeActionsOnEncrypt(attributeActions) + .keyring(keyring) + .allowedUnsignedAttributePrefix(allowedUnsignedAttributePrefix) + .algorithmSuiteId(algorithmSuiteId) + .build(); + + return DynamoDbItemEncryptor.builder() + .DynamoDbItemEncryptorConfig(itemEncryptorConfig) + .build(); + } + + /** + * Runs all configured benchmark tests. + */ + public List runAllBenchmarks() throws Exception { + System.out.println("Starting comprehensive DB-ESDK benchmark suite"); + + // Combine all data sizes + List allDataSizes = Stream.of( + config.getDataSizes().getSmall(), + config.getDataSizes().getMedium(), + config.getDataSizes().getLarge() + ).filter(Objects::nonNull) + .flatMap(List::stream) + .collect(Collectors.toList()); + + // Get allowed test types from quick config if available + List allowedTestTypes = config.getQuickConfig() != null ? + config.getQuickConfig().getTestTypes() : null; + + // Run test suites + if (Utils.shouldRunTestType("throughput", allowedTestTypes)) { + runThroughputTests(allDataSizes, config.getIterations().getMeasurement()); + } else { + System.out.println("Skipping throughput tests (not in test_types)"); + } + + if (Utils.shouldRunTestType("memory", allowedTestTypes)) { + runMemoryTests(allDataSizes); + } else { + System.out.println("Skipping memory tests (not in test_types)"); + } + + if (Utils.shouldRunTestType("concurrency", allowedTestTypes)) { + runConcurrencyTests(allDataSizes, config.getConcurrencyLevels()); + } else { + System.out.println("Skipping concurrency tests (not in test_types)"); + } + + System.out.printf("Benchmark suite completed. Total results: %d%n", results.size()); + return results; + } + + /** + * Runs throughput benchmark tests. + */ + private void runThroughputTests(List dataSizes, int iterations) throws Exception { + System.out.println("Running throughput tests..."); + for (int dataSize : dataSizes) { + BenchmarkResult result = runThroughputTest(dataSize, iterations); + if (result != null) { + results.add(result); + System.out.printf("Throughput test completed: %.2f ops/sec%n", result.getOpsPerSecond()); + } + } + } + + /** + * Runs a single throughput test. + */ + private BenchmarkResult runThroughputTest(int dataSize, int iterations) throws Exception { + System.out.printf("Running throughput test - Size: %d bytes, Iterations: %d%n", dataSize, iterations); + + byte[] testData = Utils.generateTestData(dataSize); + + // Warmup + for (int i = 0; i < config.getIterations().getWarmup(); i++) { + runItemEncryptorCycle(testData); + } + + // Measurement runs + List putLatencies = new ArrayList<>(); + List getLatencies = new ArrayList<>(); + List endToEndLatencies = new ArrayList<>(); + long totalBytes = 0; + + long startTime = System.nanoTime(); + for (int i = 0; i < iterations; i++) { + long iterationStart = System.nanoTime(); + + LatencyResult latencyResult = runItemEncryptorCycle(testData); + + long iterationDuration = System.nanoTime() - iterationStart; + double iterationMs = Utils.nanosToMillis(iterationDuration); + + putLatencies.add(latencyResult.putLatencyMs); + getLatencies.add(latencyResult.getLatencyMs); + endToEndLatencies.add(iterationMs); + totalBytes += dataSize; + } + double totalDuration = Utils.nanosToMillis(System.nanoTime() - startTime) / 1000.0; // Convert to seconds + + // Calculate metrics + double[] endToEndArray = endToEndLatencies.stream().mapToDouble(Double::doubleValue).toArray(); + Arrays.sort(endToEndArray); + + BenchmarkResult result = new BenchmarkResult("throughput", "java", dataSize, 1); + result.setPutLatencyMs(Utils.average(putLatencies)); + result.setGetLatencyMs(Utils.average(getLatencies)); + result.setEndToEndLatencyMs(Utils.average(endToEndLatencies)); + result.setOpsPerSecond(iterations / totalDuration); + result.setBytesPerSecond(totalBytes / totalDuration); + result.setP50Latency(Utils.percentile(endToEndArray, 0.50)); + result.setP95Latency(Utils.percentile(endToEndArray, 0.95)); + result.setP99Latency(Utils.percentile(endToEndArray, 0.99)); + result.setTimestamp(Utils.getCurrentTimestamp()); + result.setJavaVersion(Utils.getJavaVersion()); + result.setCpuCount(cpuCount); + result.setTotalMemoryGb(totalMemoryGb); + + System.out.printf("Throughput test completed - Ops/sec: %.2f, MB/sec: %.2f%n", + result.getOpsPerSecond(), result.getBytesPerSecond() / (1024 * 1024)); + + return result; + } + + /** + * Runs memory benchmark tests. + */ + private void runMemoryTests(List dataSizes) throws Exception { + System.out.println("Running memory tests..."); + for (int dataSize : dataSizes) { + BenchmarkResult result = runMemoryTest(dataSize); + if (result != null) { + results.add(result); + System.out.printf("Memory test completed: %.2f MB peak%n", result.getPeakMemoryMb()); + } + } + } + + /** + * Runs a single memory test with continuous monitoring. + */ + private BenchmarkResult runMemoryTest(int dataSize) throws Exception { + System.out.printf("Running memory test - Size: %d bytes (%d iterations, continuous sampling)%n", + dataSize, MEMORY_TEST_ITERATIONS); + + byte[] data = Utils.generateTestData(dataSize); + MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); + + double peakMemoryMb = 0.0; + List avgMemoryValues = new ArrayList<>(); + + // Run iterations + for (int i = 0; i < MEMORY_TEST_ITERATIONS; i++) { + Utils.forceGcAndWait(); + + long beforeHeap = memoryMXBean.getHeapMemoryUsage().getUsed(); + List samples = new ArrayList<>(); + + // Start memory sampling in background + CompletableFuture samplingTask = CompletableFuture.runAsync(() -> { + long samplingStart = System.currentTimeMillis(); + while (!Thread.currentThread().isInterrupted()) { + long currentHeap = memoryMXBean.getHeapMemoryUsage().getUsed(); + double heapDelta = Math.max(0, currentHeap - beforeHeap) / (1024.0 * 1024.0); + samples.add(new Utils.MemorySample(System.currentTimeMillis(), heapDelta, 0)); + + try { + Thread.sleep(SAMPLING_INTERVAL_MS); + } catch (InterruptedException e) { + break; + } + } + }); + + // Run operation + try { + runItemEncryptorCycle(data); + } catch (Exception e) { + System.out.printf("Iteration %d failed: %s%n", i + 1, e.getMessage()); + continue; + } + + // Stop sampling + samplingTask.cancel(true); + Thread.sleep(FINAL_SAMPLE_WAIT_MS); + + // Analyze samples + if (!samples.isEmpty()) { + double iterPeakHeap = samples.stream() + .mapToDouble(Utils.MemorySample::getHeapMb) + .max().orElse(0.0); + double iterAvgHeap = samples.stream() + .mapToDouble(Utils.MemorySample::getHeapMb) + .average().orElse(0.0); + + peakMemoryMb = Math.max(peakMemoryMb, iterPeakHeap); + avgMemoryValues.add(iterAvgHeap); + + System.out.printf("=== Iteration %d === Peak Heap: %.2f MB, Avg Heap: %.2f MB (%d samples)%n", + i + 1, iterPeakHeap, iterAvgHeap, samples.size()); + } + } + + if (avgMemoryValues.isEmpty()) { + throw new Exception("All memory test iterations failed"); + } + + double overallAvgHeap = Utils.average(avgMemoryValues); + double memoryEfficiency = overallAvgHeap > 0 ? dataSize / (overallAvgHeap * 1024 * 1024) : 0.0; + + System.out.printf("\nMemory Summary:%n"); + System.out.printf("- Absolute Peak Heap: %.2f MB (across all runs)%n", peakMemoryMb); + System.out.printf("- Average Heap: %.2f MB (across all runs)%n", overallAvgHeap); + + BenchmarkResult result = new BenchmarkResult("memory", "java", dataSize, 1); + result.setPeakMemoryMb(peakMemoryMb); + result.setMemoryEfficiencyRatio(memoryEfficiency); + result.setTimestamp(Utils.getCurrentTimestamp()); + result.setJavaVersion(Utils.getJavaVersion()); + result.setCpuCount(cpuCount); + result.setTotalMemoryGb(totalMemoryGb); + + return result; + } + + /** + * Runs concurrency benchmark tests. + */ + private void runConcurrencyTests(List dataSizes, List concurrencyLevels) throws Exception { + System.out.println("Running concurrency tests..."); + for (int dataSize : dataSizes) { + for (int concurrency : concurrencyLevels) { + if (concurrency > 1) { // Skip single-threaded + BenchmarkResult result = runConcurrentTest(dataSize, concurrency, 5); + if (result != null) { + results.add(result); + System.out.printf("Concurrent test completed: %.2f ops/sec @ %d threads%n", + result.getOpsPerSecond(), concurrency); + } + } + } + } + } + + /** + * Runs a single concurrent test. + */ + private BenchmarkResult runConcurrentTest(int dataSize, int concurrency, int iterationsPerWorker) throws Exception { + System.out.printf("Running concurrent test - Size: %d bytes, Concurrency: %d%n", dataSize, concurrency); + + byte[] data = Utils.generateTestData(dataSize); + List allTimes = Collections.synchronizedList(new ArrayList<>()); + ExecutorService executor = Executors.newFixedThreadPool(concurrency); + + long startTime = System.nanoTime(); + + try { + // Submit workers + List> futures = new ArrayList<>(); + for (int i = 0; i < concurrency; i++) { + final int workerId = i; + CompletableFuture future = CompletableFuture.runAsync(() -> { + for (int j = 0; j < iterationsPerWorker; j++) { + try { + long iterStart = System.nanoTime(); + runItemEncryptorCycle(data); + double iterMs = Utils.nanosToMillis(System.nanoTime() - iterStart); + allTimes.add(iterMs); + } catch (Exception e) { + throw new RuntimeException(String.format("Worker %d iteration %d failed: %s", + workerId, j, e.getMessage()), e); + } + } + }, executor); + futures.add(future); + } + + // Wait for all workers to complete + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(); + + } finally { + executor.shutdown(); + } + + double totalDurationSec = Utils.nanosToMillis(System.nanoTime() - startTime) / 1000.0; + + // Calculate metrics + int totalOps = concurrency * iterationsPerWorker; + long totalBytes = (long) totalOps * dataSize; + + double[] timesArray = allTimes.stream().mapToDouble(Double::doubleValue).toArray(); + Arrays.sort(timesArray); + + BenchmarkResult result = new BenchmarkResult("concurrent", "java", dataSize, concurrency); + result.setEndToEndLatencyMs(Utils.average(timesArray)); + result.setOpsPerSecond(totalOps / totalDurationSec); + result.setBytesPerSecond(totalBytes / totalDurationSec); + result.setP50Latency(Utils.percentile(timesArray, 0.50)); + result.setP95Latency(Utils.percentile(timesArray, 0.95)); + result.setP99Latency(Utils.percentile(timesArray, 0.99)); + result.setTimestamp(Utils.getCurrentTimestamp()); + result.setJavaVersion(Utils.getJavaVersion()); + result.setCpuCount(cpuCount); + result.setTotalMemoryGb(totalMemoryGb); + + System.out.printf("Concurrent test completed - Ops/sec: %.2f, Avg latency: %.2f ms%n", + result.getOpsPerSecond(), result.getEndToEndLatencyMs()); + + return result; + } + + /** + * Performs a single encrypt-decrypt cycle and measures performance. + */ + private LatencyResult runItemEncryptorCycle(byte[] data) throws Exception { + // Create DynamoDB item + Map item = new HashMap<>(); + item.put("partition_key", AttributeValue.builder().s("benchmark-test").build()); + item.put("sort_key", AttributeValue.builder().n("0").build()); + + Map nestedMap = new HashMap<>(); + nestedMap.put("data", AttributeValue.builder().b(SdkBytes.fromByteArray(data)).build()); + item.put("attribute1", AttributeValue.builder().m(nestedMap).build()); + + item.put("attribute2", AttributeValue.builder().s("sign me!").build()); + item.put(":attribute3", AttributeValue.builder().s("ignore me!").build()); + + // Encrypt item + long encryptStart = System.nanoTime(); + EncryptItemInput encryptInput = EncryptItemInput.builder().plaintextItem(item).build(); + EncryptItemOutput encryptOutput = itemEncryptor.EncryptItem(encryptInput); + double putLatencyMs = Utils.nanosToMillis(System.nanoTime() - encryptStart); + + Map encryptedItem = encryptOutput.encryptedItem(); + + // Decrypt item + long decryptStart = System.nanoTime(); + DecryptItemInput decryptInput = DecryptItemInput.builder().encryptedItem(encryptedItem).build(); + DecryptItemOutput decryptOutput = itemEncryptor.DecryptItem(decryptInput); + double getLatencyMs = Utils.nanosToMillis(System.nanoTime() - decryptStart); + + Map decryptedItem = decryptOutput.plaintextItem(); + + // Verify items match (basic check) + if (!item.equals(decryptedItem)) { + throw new RuntimeException("Decrypted item does not match original item"); + } + + return new LatencyResult(putLatencyMs, getLatencyMs); + } + + /** + * Saves benchmark results to JSON file. + */ + public void saveResults(String outputPath) throws IOException { + // Ensure output directory exists + Path outputFilePath = Paths.get(outputPath); + Files.createDirectories(outputFilePath.getParent()); + + // Create results structure matching Go implementation + Map resultsData = new HashMap<>(); + + Map metadata = new HashMap<>(); + metadata.put("language", "java"); + metadata.put("timestamp", Utils.getCurrentTimestamp()); + metadata.put("java_version", Utils.getJavaVersion()); + metadata.put("cpu_count", cpuCount); + metadata.put("total_memory_gb", totalMemoryGb); + metadata.put("total_tests", results.size()); + + resultsData.put("metadata", metadata); + resultsData.put("results", results); + + // Write to JSON file with proper formatting + ObjectMapper mapper = new ObjectMapper(); + mapper.writerWithDefaultPrettyPrinter().writeValue(new File(outputPath), resultsData); + + System.out.printf("Results saved to: %s%n", outputPath); + } + + // Getters + public TestConfig getConfig() { return config; } + public List getResults() { return results; } + + /** + * Helper class to hold latency results. + */ + private static class LatencyResult { + final double putLatencyMs; + final double getLatencyMs; + + LatencyResult(double putLatencyMs, double getLatencyMs) { + this.putLatencyMs = putLatencyMs; + this.getLatencyMs = getLatencyMs; + } + } +} diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java new file mode 100644 index 0000000000..f68a48ba7f --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java @@ -0,0 +1,65 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.amazon.dbesdk.benchmark; + +import software.amazon.cryptography.materialproviders.IKeyring; +import software.amazon.cryptography.materialproviders.MaterialProviders; +import software.amazon.cryptography.materialproviders.model.AesWrappingAlg; +import software.amazon.cryptography.materialproviders.model.CreateRawAesKeyringInput; +import software.amazon.cryptography.materialproviders.model.MaterialProvidersConfig; + +import java.security.SecureRandom; +import java.util.Map; + +/** + * Helper class for setting up keyrings for DB-ESDK benchmarks. + */ +public class KeyringSetup { + + private static final String RAW_AES_KEYRING = "raw-aes"; + + /** + * Creates a keyring based on the specified type. + * + * @param keyringType The type of keyring to create + * @return The configured keyring + * @throws Exception if keyring creation fails + */ + public static IKeyring createKeyring(String keyringType) throws Exception { + if (RAW_AES_KEYRING.equals(keyringType)) { + return createRawAesKeyring(); + } else { + throw new IllegalArgumentException("Unsupported keyring type: " + keyringType); + } + } + + /** + * Creates a Raw AES keyring with a randomly generated 256-bit key. + * This matches the Go implementation's keyring setup. + * + * @return Raw AES keyring + * @throws Exception if keyring creation fails + */ + private static IKeyring createRawAesKeyring() throws Exception { + // Initialize Material Providers client + MaterialProviders matProv = MaterialProviders.builder() + .MaterialProvidersConfig(MaterialProvidersConfig.builder().build()) + .build(); + + // Generate a 256-bit (32-byte) random key + byte[] key = new byte[32]; + new SecureRandom().nextBytes(key); + + // Create Raw AES keyring input + CreateRawAesKeyringInput keyringInput = CreateRawAesKeyringInput.builder() + .keyName("test-aes-256-key") + .keyNamespace("DB-ESDK-performance-test") + .wrappingKey(key) + .wrappingAlg(AesWrappingAlg.ALG_AES256_GCM_IV12_TAG16) + .build(); + + // Create and return the keyring + return matProv.CreateRawAesKeyring(keyringInput); + } +} diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java new file mode 100644 index 0000000000..2bda04fe78 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java @@ -0,0 +1,223 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.amazon.dbesdk.benchmark; + +import org.apache.commons.cli.*; + +import java.io.IOException; +import java.util.List; + +/** + * Main entry point for the DB-ESDK Java performance benchmark. + */ +public class Program { + + public static void main(String[] args) { + CommandLineOptions options = parseArgs(args); + if (options == null) { + return; + } + + try { + // Initialize benchmark + DBESDKBenchmark benchmark = new DBESDKBenchmark(options.getConfigPath()); + + // Adjust config for quick test if requested + if (options.isQuickTest()) { + benchmark.getConfig().adjustForQuickTest(); + } + + System.out.println("\n=== Starting DB-ESDK Java Benchmark ==="); + System.out.printf("Configuration: %s%n", options.getConfigPath()); + System.out.printf("Output: %s%n", options.getOutputPath()); + System.out.printf("Quick mode: %s%n", options.isQuickTest()); + System.out.printf("System: %d CPU cores, %.1f GB memory%n", + Utils.getCpuCount(), Utils.getTotalMemoryGb()); + + // Run benchmarks + List results = benchmark.runAllBenchmarks(); + + // Save results + benchmark.saveResults(options.getOutputPath()); + + // Print summary + printSummary(results, options.getOutputPath()); + + } catch (Exception e) { + System.err.println("Benchmark failed: " + e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + } + + /** + * Parses command line arguments. + */ + private static CommandLineOptions parseArgs(String[] args) { + Options options = new Options(); + + options.addOption(Option.builder("c") + .longOpt("config") + .hasArg() + .argName("file") + .desc("Path to test configuration file (default: ../config/test-scenarios.yaml)") + .build()); + + options.addOption(Option.builder("o") + .longOpt("output") + .hasArg() + .argName("file") + .desc("Path to output results file (default: ../results/raw-data/java_results.json)") + .build()); + + options.addOption(Option.builder("q") + .longOpt("quick") + .desc("Run quick test with reduced iterations") + .build()); + + options.addOption(Option.builder("h") + .longOpt("help") + .desc("Show this help message") + .build()); + + CommandLineParser parser = new DefaultParser(); + try { + CommandLine cmd = parser.parse(options, args); + + if (cmd.hasOption("h")) { + printUsage(options); + return null; + } + + String configPath = cmd.getOptionValue("c", "../config/test-scenarios.yaml"); + String outputPath = cmd.getOptionValue("o", "../results/raw-data/java_results.json"); + boolean quickTest = cmd.hasOption("q"); + + return new CommandLineOptions(configPath, outputPath, quickTest); + + } catch (ParseException e) { + System.err.println("Error parsing command line: " + e.getMessage()); + printUsage(options); + return null; + } + } + + /** + * Prints usage information. + */ + private static void printUsage(Options options) { + HelpFormatter formatter = new HelpFormatter(); + System.out.println("DB-ESDK Java Performance Benchmark"); + System.out.println(); + formatter.printHelp("java -jar db-esdk-benchmark.jar [options]", options); + System.out.println(); + System.out.println("Examples:"); + System.out.println(" # Run quick benchmark"); + System.out.println(" java -jar db-esdk-benchmark.jar --quick"); + System.out.println(); + System.out.println(" # Run full benchmark with custom config"); + System.out.println(" java -jar db-esdk-benchmark.jar -c /path/to/config.yaml -o /path/to/results.json"); + System.out.println(); + System.out.println(" # Using Gradle"); + System.out.println(" ./gradlew run --args=\"--quick\""); + } + + /** + * Prints benchmark summary. + */ + private static void printSummary(List results, String outputPath) { + System.out.println("\n=== DB-ESDK Java Benchmark Summary ==="); + System.out.printf("Total tests completed: %d%n", results.size()); + System.out.printf("Results saved to: %s%n", outputPath); + + if (!results.isEmpty()) { + // Find maximum throughput + double maxThroughput = results.stream() + .filter(r -> "throughput".equals(r.getTestName())) + .mapToDouble(BenchmarkResult::getOpsPerSecond) + .max() + .orElse(0.0); + + if (maxThroughput > 0) { + System.out.printf("Maximum throughput: %.2f ops/sec%n", maxThroughput); + } + + // Print some sample results by test type + System.out.println(); + printTestTypeSummary(results, "throughput"); + printTestTypeSummary(results, "memory"); + printTestTypeSummary(results, "concurrent"); + } + + System.out.println("\n=== Benchmark Complete ==="); + } + + /** + * Prints summary for a specific test type. + */ + private static void printTestTypeSummary(List results, String testType) { + List testResults = results.stream() + .filter(r -> testType.equals(r.getTestName())) + .toList(); + + if (testResults.isEmpty()) { + return; + } + + System.out.printf("\n%s Tests (%d results):%n", + testType.substring(0, 1).toUpperCase() + testType.substring(1), + testResults.size()); + + if ("throughput".equals(testType)) { + testResults.stream() + .limit(3) // Show first 3 results + .forEach(r -> System.out.printf(" %s: %.2f ops/sec, %.2f ms latency%n", + formatDataSize(r.getDataSize()), r.getOpsPerSecond(), r.getEndToEndLatencyMs())); + } else if ("memory".equals(testType)) { + testResults.stream() + .limit(3) + .forEach(r -> System.out.printf(" %s: %.2f MB peak, %.4f efficiency%n", + formatDataSize(r.getDataSize()), r.getPeakMemoryMb(), r.getMemoryEfficiencyRatio())); + } else if ("concurrent".equals(testType)) { + testResults.stream() + .limit(3) + .forEach(r -> System.out.printf(" %s (%d threads): %.2f ops/sec%n", + formatDataSize(r.getDataSize()), r.getConcurrency(), r.getOpsPerSecond())); + } + } + + /** + * Formats data size for display. + */ + private static String formatDataSize(int bytes) { + if (bytes >= 1024 * 1024 * 1024) { + return String.format("%.0f GB", bytes / (1024.0 * 1024.0 * 1024.0)); + } else if (bytes >= 1024 * 1024) { + return String.format("%.0f MB", bytes / (1024.0 * 1024.0)); + } else if (bytes >= 1024) { + return String.format("%.0f KB", bytes / 1024.0); + } else { + return bytes + " B"; + } + } + + /** + * Command line options holder. + */ + public static class CommandLineOptions { + private final String configPath; + private final String outputPath; + private final boolean quickTest; + + public CommandLineOptions(String configPath, String outputPath, boolean quickTest) { + this.configPath = configPath; + this.outputPath = outputPath; + this.quickTest = quickTest; + } + + public String getConfigPath() { return configPath; } + public String getOutputPath() { return outputPath; } + public boolean isQuickTest() { return quickTest; } + } +} diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java new file mode 100644 index 0000000000..edfbb4c465 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java @@ -0,0 +1,195 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.amazon.dbesdk.benchmark; + +import org.yaml.snakeyaml.Yaml; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * Configuration class for DB-ESDK benchmark tests, loaded from YAML. + */ +public class TestConfig { + private DataSizes dataSizes; + private Iterations iterations; + private List concurrencyLevels; + private QuickConfig quickConfig; + private String tableName; + private String keyring; + + // Nested classes for structured configuration + public static class DataSizes { + private List small; + private List medium; + private List large; + + public List getSmall() { return small; } + public void setSmall(List small) { this.small = small; } + + public List getMedium() { return medium; } + public void setMedium(List medium) { this.medium = medium; } + + public List getLarge() { return large; } + public void setLarge(List large) { this.large = large; } + } + + public static class Iterations { + private int warmup; + private int measurement; + + public int getWarmup() { return warmup; } + public void setWarmup(int warmup) { this.warmup = warmup; } + + public int getMeasurement() { return measurement; } + public void setMeasurement(int measurement) { this.measurement = measurement; } + } + + public static class QuickConfig { + private DataSizes dataSizes; + private Iterations iterations; + private List concurrencyLevels; + private List testTypes; + + public DataSizes getDataSizes() { return dataSizes; } + public void setDataSizes(DataSizes dataSizes) { this.dataSizes = dataSizes; } + + public Iterations getIterations() { return iterations; } + public void setIterations(Iterations iterations) { this.iterations = iterations; } + + public List getConcurrencyLevels() { return concurrencyLevels; } + public void setConcurrencyLevels(List concurrencyLevels) { this.concurrencyLevels = concurrencyLevels; } + + public List getTestTypes() { return testTypes; } + public void setTestTypes(List testTypes) { this.testTypes = testTypes; } + } + + // Main getters and setters + public DataSizes getDataSizes() { return dataSizes; } + public void setDataSizes(DataSizes dataSizes) { this.dataSizes = dataSizes; } + + public Iterations getIterations() { return iterations; } + public void setIterations(Iterations iterations) { this.iterations = iterations; } + + public List getConcurrencyLevels() { return concurrencyLevels; } + public void setConcurrencyLevels(List concurrencyLevels) { this.concurrencyLevels = concurrencyLevels; } + + public QuickConfig getQuickConfig() { return quickConfig; } + public void setQuickConfig(QuickConfig quickConfig) { this.quickConfig = quickConfig; } + + public String getTableName() { return tableName; } + public void setTableName(String tableName) { this.tableName = tableName; } + + public String getKeyring() { return keyring; } + public void setKeyring(String keyring) { this.keyring = keyring; } + + /** + * Loads test configuration from YAML file. + */ + public static TestConfig loadConfig(String configPath) throws IOException { + Yaml yaml = new Yaml(); + try (FileInputStream fis = new FileInputStream(configPath)) { + Map yamlData = yaml.load(fis); + return parseYamlToConfig(yamlData); + } + } + + /** + * Parses the YAML data structure into TestConfig object. + */ + @SuppressWarnings("unchecked") + private static TestConfig parseYamlToConfig(Map yamlData) { + TestConfig config = new TestConfig(); + + // Parse data_sizes + if (yamlData.containsKey("data_sizes")) { + Map dataSizesMap = (Map) yamlData.get("data_sizes"); + DataSizes dataSizes = new DataSizes(); + dataSizes.setSmall((List) dataSizesMap.get("small")); + dataSizes.setMedium((List) dataSizesMap.get("medium")); + dataSizes.setLarge((List) dataSizesMap.get("large")); + config.setDataSizes(dataSizes); + } + + // Parse iterations + if (yamlData.containsKey("iterations")) { + Map iterationsMap = (Map) yamlData.get("iterations"); + Iterations iterations = new Iterations(); + iterations.setWarmup((Integer) iterationsMap.get("warmup")); + iterations.setMeasurement((Integer) iterationsMap.get("measurement")); + config.setIterations(iterations); + } + + // Parse concurrency_levels + if (yamlData.containsKey("concurrency_levels")) { + config.setConcurrencyLevels((List) yamlData.get("concurrency_levels")); + } + + // Parse quick_config + if (yamlData.containsKey("quick_config")) { + Map quickConfigMap = (Map) yamlData.get("quick_config"); + QuickConfig quickConfig = new QuickConfig(); + + // Parse quick_config data_sizes + if (quickConfigMap.containsKey("data_sizes")) { + Map quickDataSizesMap = (Map) quickConfigMap.get("data_sizes"); + DataSizes quickDataSizes = new DataSizes(); + quickDataSizes.setSmall((List) quickDataSizesMap.get("small")); + quickConfig.setDataSizes(quickDataSizes); + } + + // Parse quick_config iterations + if (quickConfigMap.containsKey("iterations")) { + Map quickIterationsMap = (Map) quickConfigMap.get("iterations"); + Iterations quickIterations = new Iterations(); + quickIterations.setWarmup((Integer) quickIterationsMap.get("warmup")); + quickIterations.setMeasurement((Integer) quickIterationsMap.get("measurement")); + quickConfig.setIterations(quickIterations); + } + + // Parse quick_config concurrency_levels and test_types + if (quickConfigMap.containsKey("concurrency_levels")) { + quickConfig.setConcurrencyLevels((List) quickConfigMap.get("concurrency_levels")); + } + if (quickConfigMap.containsKey("test_types")) { + quickConfig.setTestTypes((List) quickConfigMap.get("test_types")); + } + + config.setQuickConfig(quickConfig); + } + + // Parse table_name and keyring + config.setTableName((String) yamlData.get("table_name")); + config.setKeyring((String) yamlData.get("keyring")); + + return config; + } + + /** + * Adjusts configuration for quick test mode. + */ + public void adjustForQuickTest() { + if (quickConfig == null) { + throw new IllegalStateException("Quick mode requested but no quick_config found in config file"); + } + + // Apply quick config settings + this.iterations.setMeasurement(quickConfig.getIterations().getMeasurement()); + this.iterations.setWarmup(quickConfig.getIterations().getWarmup()); + + // Replace data sizes with quick config + if (quickConfig.getDataSizes() != null) { + this.dataSizes.setSmall(quickConfig.getDataSizes().getSmall()); + this.dataSizes.setMedium(List.of()); // Empty list + this.dataSizes.setLarge(List.of()); // Empty list + } + + // Replace concurrency levels + if (quickConfig.getConcurrencyLevels() != null) { + this.concurrencyLevels = quickConfig.getConcurrencyLevels(); + } + } +} diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java new file mode 100644 index 0000000000..0d70b7b421 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java @@ -0,0 +1,207 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.amazon.dbesdk.benchmark; + +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryMXBean; +import java.security.SecureRandom; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.List; + +/** + * Utility functions for benchmark operations. + */ +public class Utils { + + private static final SecureRandom RANDOM = new SecureRandom(); + private static final DateTimeFormatter TIMESTAMP_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + /** + * Calculates the average of a list of double values. + */ + public static double average(List values) { + if (values.isEmpty()) { + return 0.0; + } + return values.stream().mapToDouble(Double::doubleValue).average().orElse(0.0); + } + + /** + * Calculates the average of an array of double values. + */ + public static double average(double[] values) { + if (values.length == 0) { + return 0.0; + } + return Arrays.stream(values).average().orElse(0.0); + } + + /** + * Calculates the specified percentile from a sorted array of values. + * + * @param sortedValues Sorted array of values + * @param percentile Percentile to calculate (0.0 to 1.0) + * @return The percentile value + */ + public static double percentile(double[] sortedValues, double percentile) { + if (sortedValues.length == 0) { + return 0.0; + } + if (percentile <= 0.0) { + return sortedValues[0]; + } + if (percentile >= 1.0) { + return sortedValues[sortedValues.length - 1]; + } + + double index = percentile * (sortedValues.length - 1); + int lower = (int) Math.floor(index); + int upper = (int) Math.ceil(index); + + if (lower == upper) { + return sortedValues[lower]; + } + + double weight = index - lower; + return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight; + } + + /** + * Generates random test data of specified size. + * + * @param size Size in bytes + * @return Random byte array + */ + public static byte[] generateTestData(int size) { + byte[] data = new byte[size]; + RANDOM.nextBytes(data); + return data; + } + + /** + * Gets the current timestamp in the format used by the Go implementation. + */ + public static String getCurrentTimestamp() { + return LocalDateTime.now().format(TIMESTAMP_FORMAT); + } + + /** + * Gets the Java version string. + */ + public static String getJavaVersion() { + return System.getProperty("java.version"); + } + + /** + * Gets the number of available CPU cores. + */ + public static int getCpuCount() { + return Runtime.getRuntime().availableProcessors(); + } + + /** + * Gets the total system memory in GB. + */ + public static double getTotalMemoryGb() { + MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); + long maxMemory = memoryMXBean.getHeapMemoryUsage().getMax(); + if (maxMemory == -1) { + // If max heap is not set, use the current committed memory as approximation + maxMemory = memoryMXBean.getHeapMemoryUsage().getCommitted(); + } + return maxMemory / (1024.0 * 1024.0 * 1024.0); + } + + /** + * Gets the current memory usage in MB. + */ + public static double getCurrentMemoryUsageMb() { + MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); + long usedMemory = memoryMXBean.getHeapMemoryUsage().getUsed(); + return usedMemory / (1024.0 * 1024.0); + } + + /** + * Forces garbage collection and waits a short time for it to settle. + */ + public static void forceGcAndWait() { + System.gc(); + try { + Thread.sleep(5); // 5ms settle time, matching Go's GCSettleTimeMs + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + + /** + * Converts milliseconds to seconds. + */ + public static double msToSeconds(double milliseconds) { + return milliseconds / 1000.0; + } + + /** + * Converts nanoseconds to milliseconds. + */ + public static double nanosToMillis(long nanoseconds) { + return nanoseconds / 1_000_000.0; + } + + /** + * Checks if a test type should be run based on quick config test types. + * + * @param testType The test type to check + * @param allowedTypes List of allowed test types (null means all are allowed) + * @return true if the test should run + */ + public static boolean shouldRunTestType(String testType, List allowedTypes) { + if (allowedTypes == null || allowedTypes.isEmpty()) { + return true; + } + return allowedTypes.contains(testType); + } + + /** + * Formats a double value to 2 decimal places. + */ + public static String formatDouble(double value) { + return String.format("%.2f", value); + } + + /** + * Formats bytes per second to a human-readable format. + */ + public static String formatBytesPerSecond(double bytesPerSecond) { + if (bytesPerSecond >= 1_000_000_000) { + return String.format("%.2f GB/sec", bytesPerSecond / 1_000_000_000); + } else if (bytesPerSecond >= 1_000_000) { + return String.format("%.2f MB/sec", bytesPerSecond / 1_000_000); + } else if (bytesPerSecond >= 1_000) { + return String.format("%.2f KB/sec", bytesPerSecond / 1_000); + } else { + return String.format("%.2f B/sec", bytesPerSecond); + } + } + + /** + * Memory sample class for continuous memory monitoring. + */ + public static class MemorySample { + private final long timestamp; + private final double heapMb; + private final double allocatedMb; + + public MemorySample(long timestamp, double heapMb, double allocatedMb) { + this.timestamp = timestamp; + this.heapMb = heapMb; + this.allocatedMb = allocatedMb; + } + + public long getTimestamp() { return timestamp; } + public double getHeapMb() { return heapMb; } + public double getAllocatedMb() { return allocatedMb; } + } +} From d76fe17712de817759d9dea7469c6dcefd45422e Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 12:02:04 -0800 Subject: [PATCH 02/12] m --- .../benchmarks/java/.gitignore | 1 + .../.gradle/8.14/checksums/checksums.lock | Bin 17 -> 0 bytes .../.gradle/8.14/checksums/sha1-checksums.bin | Bin 18659 -> 0 bytes .../executionHistory/executionHistory.bin | Bin 19986 -> 0 bytes .../executionHistory/executionHistory.lock | Bin 17 -> 0 bytes .../.gradle/8.14/fileChanges/last-build.bin | Bin 1 -> 0 bytes .../.gradle/8.14/fileHashes/fileHashes.bin | Bin 19147 -> 0 bytes .../.gradle/8.14/fileHashes/fileHashes.lock | Bin 17 -> 0 bytes .../java/.gradle/8.14/gc.properties | 0 .../buildOutputCleanup.lock | Bin 17 -> 0 bytes .../buildOutputCleanup/cache.properties | 2 - .../buildOutputCleanup/outputFiles.bin | Bin 18767 -> 0 bytes .../benchmarks/java/.gradle/file-system.probe | Bin 8 -> 0 bytes .../java/.gradle/vcs-1/gc.properties | 0 .../benchmarks/java/build.gradle.kts | 97 ++++++++++++------ 15 files changed, 66 insertions(+), 34 deletions(-) create mode 100644 db-esdk-performance-testing/benchmarks/java/.gitignore delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/checksums.lock delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/sha1-checksums.bin delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.bin delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.lock delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileChanges/last-build.bin delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.bin delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.lock delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/8.14/gc.properties delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/buildOutputCleanup.lock delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/outputFiles.bin delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/file-system.probe delete mode 100644 db-esdk-performance-testing/benchmarks/java/.gradle/vcs-1/gc.properties diff --git a/db-esdk-performance-testing/benchmarks/java/.gitignore b/db-esdk-performance-testing/benchmarks/java/.gitignore new file mode 100644 index 0000000000..ac96206f31 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/java/.gitignore @@ -0,0 +1 @@ +.gradle/ \ No newline at end of file diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/checksums.lock b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/checksums.lock deleted file mode 100644 index 3749592ae527b5a05000497cd77e570131d35c3a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 UcmZRsVwpUpcQxx01_)pU04tsYj{pDw diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/sha1-checksums.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/checksums/sha1-checksums.bin deleted file mode 100644 index ca074afd2955fd901701ceef698a737ea816e2f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18659 zcmeI(JxGE<9LMof$>;^LD6l13+6<&1X(%Z&E0+)r3a6G_f*@3aq9J%7m)4$g4~l4U z5J#INa8YPATuK6o-rVZ0=XnrmZi(-~J@@B#{Ga1K>%+4kgxmFH4$&Gzt&$1>1Q0*~ z0R#|0009ILKmY**5I_I{1Q0*~0R;YwKvZ6&+qjI|V^>9AN(gVSEF4GGkT+J?x-+(y z=B)1r;bHx(o~~?|dCJQ7*Jelh3(bg`Ut77g%6#3}UYZyq%Dk`T7@hsVzob-E+}mXOOtdspzd81s+%KH`~9E&mdqPwcLg tf4ZLh#yo0SHsI0st-TB?##1!pJ8?z)@kLBqycFjW%QYA?&1nV0NjXLpA8 z-tL;5JhZ4JB#I)6|Db}PpdKWG7txFLQVY_kP?dlPB8Y_wqN4WgZk9y!ASfvE9hjNN z%$xW7{XX;CxonD%CjHgaMy9u~riU0o00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$## zAn>^eq*WoaYsEAz3snYl%Y?LisRmk$J%4j(&haC)+iO?X|39do)%B&ddpJS>0uX=z z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV= z5P$##An+*&La{Gnw!i>~MN+T0Cfra8llg^ca_qR3fmbA8m7iBpzLw715Rt?ls^ zr#+GAYiqNk@wnqSi71OD_2fx?pVt3`pU8^WvzwjYqy|&<60`8j` zus2KF;>&xBdGgw08wUf{cWGZ zy-WL)|l+!2-?uj-}=rmC1(c_dcKJX~AZOWJ0=ye$!G9W%HEhR3KWSQUGqA(<(Wl z|Fz*(&&v~&|NJs>fBp6S9kJnR?vE!z;jw`GibA?fRBO2NDb_HZBhkm5l?TtKC$B%a z`FG#VMWbhHr99Wd!=m~@saEkq`wwtx9=UVdLK@OHT4bu F^M7uRT_*ql diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.lock b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/executionHistory/executionHistory.lock deleted file mode 100644 index 81059cc752d87e9658f2ad8a408a660cf1400e67..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 UcmZQRp8Fzs$@>W!3=qH!06oqG(EtDd diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileChanges/last-build.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileChanges/last-build.bin deleted file mode 100644 index f76dd238ade08917e6712764a16a22005a50573d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1 IcmZPo000310RR91 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/fileHashes/fileHashes.bin deleted file mode 100644 index 16ad5901b7af88f78680b96e8aca8864cb2bad22..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19147 zcmeI(ZAcSg00;1A*{r7GD6C0Jt|k`)nJ&Y`D z#lpnDkdO#pcH+l``?XE#G+Er~lsx+Xfum!pJ)vEj%H^s=n!j_-lb<8*AudmiqPfeJ zZxVOUsQ7hW(_9>&U(d9pH}Kbc(R`gH=W6-4$vXb}SenP2@O2J1<~jMip62m3W5A8p z&}@F49GYvoPW6O*eXQj3I-2KPzBvB5^k6ratA=QvTYRsequ;WMUw;kF3v+8fy0_27 z^Vb__ZZwTI_Qq{w_`Hec^hk&(g*%5m1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U< z00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafK;Yj9M6$Qp#%}V3O=|S|5ELYO zQNO7`seHK85X!#k&Wug;C9o&i;d7qdg?l!v>QT*ni{q{C%|!ZOZ4CQP{$j&tu|V!m z3ma`G=Mpr_=TOkwAo=yv?Dy!ieQQSQ?2MZgK`Z} zR?YIpN_mo7*eJUco29=yoIJ<;QhUksJC`@elj!%thB|pN)Fdh0|0Pj#eecYUT^H05IPJn*aa+ diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/gc.properties b/db-esdk-performance-testing/benchmarks/java/.gradle/8.14/gc.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/buildOutputCleanup.lock deleted file mode 100644 index 72e392186a6aae9a45f81a7c05a80b7a423d1ca2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 UcmZSHdQ9T$fp4B(3=kj$06qr<=Kufz diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties b/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties deleted file mode 100644 index e5ee10e4d5..0000000000 --- a/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/cache.properties +++ /dev/null @@ -1,2 +0,0 @@ -#Wed Jan 21 10:54:09 PST 2026 -gradle.version=8.14 diff --git a/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/outputFiles.bin b/db-esdk-performance-testing/benchmarks/java/.gradle/buildOutputCleanup/outputFiles.bin deleted file mode 100644 index db5637287f664a6c3711624cc7bc2ed4ce640027..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18767 zcmeI%Pbfoi0KoCzl$JlSi<)TVrlw3p$qFg9!<0qIO|iocQnLIhkwoL>pca=&E)J5W zWJ;zMmlX%M*@%&~(#l0_-tX6v+fLH=)$hGu-}ig3_xoI5mk>t7r#wXNsK`y3A%Fk^ z2q1s}0tg_000IagfB*srAbFBYx$cvSZ%Uq>G{1M_mdUiFjE#IxP*sg>(TR1Z5s)!p0POWF5S zkDk2++k=C4**jEE7rvV&KMs0jcd9N77kAgQsVCW2RPVc8+HF49CuBcWePDmp?Qn%} zWRIvmWLj^E&eXKZ?o-{hI2TJUIKx`ESydlT97m4sw@T#txauDF#$&1>ZIwN(`g9=X zziO-U$@iF5S63l)Q`$Yw2q1s}0tg_000IagfB*srAb("fatJar") { } } -// Run task configuration for easier command line usage tasks.named("run") { standardInput = System.`in` - if (project.hasProperty("args")) { - args = (project.property("args") as String).split(" ") - } } From 265f99cd5634a44f64e148d1115f842212e6cce7 Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 12:08:44 -0800 Subject: [PATCH 03/12] m --- .../benchmarks/java/.gitignore | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/db-esdk-performance-testing/benchmarks/java/.gitignore b/db-esdk-performance-testing/benchmarks/java/.gitignore index ac96206f31..fc0da9928d 100644 --- a/db-esdk-performance-testing/benchmarks/java/.gitignore +++ b/db-esdk-performance-testing/benchmarks/java/.gitignore @@ -1 +1,15 @@ -.gradle/ \ No newline at end of file +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build + +# Ignore bin +bin + +# JetBrains +.idea/* +*.iml + +# Mac OS X +.DS_Store From 49bf8f26f14b160b66f538c7111cf2f89c2ad28f Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 13:06:01 -0800 Subject: [PATCH 04/12] m --- .../benchmarks/java/build.gradle.kts | 11 +- .../dbesdk/benchmark/DBESDKBenchmark.java | 230 +++++++++++++----- .../amazon/dbesdk/benchmark/KeyringSetup.java | 3 +- .../results/raw-data/java_results.json | 68 ++++++ 4 files changed, 250 insertions(+), 62 deletions(-) create mode 100644 db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json diff --git a/db-esdk-performance-testing/benchmarks/java/build.gradle.kts b/db-esdk-performance-testing/benchmarks/java/build.gradle.kts index b1f2b2754d..c2d755e687 100644 --- a/db-esdk-performance-testing/benchmarks/java/build.gradle.kts +++ b/db-esdk-performance-testing/benchmarks/java/build.gradle.kts @@ -75,13 +75,22 @@ dependencies { implementation("software.amazon.smithy.dafny:conversion:${smithyDafnyJavaConversionVersion}") implementation("software.amazon.cryptography:aws-cryptographic-material-providers:${mplVersion}") implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:${ddbecVersion}") - implementation("software.amazon.cryptography:TestAwsCryptographicMaterialProviders:${mplVersion}") implementation(platform("software.amazon.awssdk:bom:2.30.18")) implementation("software.amazon.awssdk:dynamodb") implementation("software.amazon.awssdk:dynamodb-enhanced") implementation("software.amazon.awssdk:core:2.30.18") implementation("software.amazon.awssdk:kms") + + // Apache Commons CLI for command line parsing + implementation("commons-cli:commons-cli:1.5.0") + + // SnakeYAML for YAML configuration parsing + implementation("org.yaml:snakeyaml:2.0") + + // Jackson for JSON output + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2") + testImplementation("com.amazonaws:DynamoDBLocal:2.+") // This is where we gather the SQLLite files to copy over dynamodb("com.amazonaws:DynamoDBLocal:2.+") diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java index 1153de9f51..effe5f9233 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java @@ -228,90 +228,193 @@ private void runMemoryTests(List dataSizes) throws Exception { } /** - * Runs a single memory test with continuous monitoring. + * Gets the total allocated bytes for the current thread. + */ + private static long getTotalAllocatedBytes() { + final var threadBean = ManagementFactory.getThreadMXBean(); + final var sunThreadBean = (com.sun.management.ThreadMXBean) threadBean; + + if (!sunThreadBean.isThreadAllocatedMemoryEnabled()) { + sunThreadBean.setThreadAllocatedMemoryEnabled(true); + } + + return sunThreadBean.getCurrentThreadAllocatedBytes(); + } + + /** + * Runs a single memory test with enhanced continuous monitoring. */ private BenchmarkResult runMemoryTest(int dataSize) throws Exception { System.out.printf("Running memory test - Size: %d bytes (%d iterations, continuous sampling)%n", dataSize, MEMORY_TEST_ITERATIONS); + System.out.flush(); byte[] data = Utils.generateTestData(dataSize); - MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); + MemoryResults memoryResults = sampleMemoryDuringOperations(data); + + if (memoryResults == null) { + throw new RuntimeException( + "Memory test failed: Unable to collect memory samples for data size " + + dataSize + " bytes" + ); + } + + BenchmarkResult result = new BenchmarkResult("memory", "java", dataSize, 1); + result.setPeakMemoryMb(memoryResults.peakMemoryMb); + result.setMemoryEfficiencyRatio(memoryResults.peakMemoryMb > 0 ? + dataSize / (memoryResults.peakMemoryMb * 1024 * 1024) : 0.0); + result.setTimestamp(Utils.getCurrentTimestamp()); + result.setJavaVersion(Utils.getJavaVersion()); + result.setCpuCount(cpuCount); + result.setTotalMemoryGb(totalMemoryGb); - double peakMemoryMb = 0.0; + return result; + } + + /** + * Samples memory usage during multiple test iterations. + */ + private MemoryResults sampleMemoryDuringOperations(byte[] data) { + double peakMemoryDelta = 0.0; + double peakAllocations = 0.0; List avgMemoryValues = new ArrayList<>(); - // Run iterations for (int i = 0; i < MEMORY_TEST_ITERATIONS; i++) { - Utils.forceGcAndWait(); - - long beforeHeap = memoryMXBean.getHeapMemoryUsage().getUsed(); - List samples = new ArrayList<>(); + IterationResult iterationResult = runSingleMemoryIteration(data, i + 1); - // Start memory sampling in background - CompletableFuture samplingTask = CompletableFuture.runAsync(() -> { - long samplingStart = System.currentTimeMillis(); - while (!Thread.currentThread().isInterrupted()) { - long currentHeap = memoryMXBean.getHeapMemoryUsage().getUsed(); - double heapDelta = Math.max(0, currentHeap - beforeHeap) / (1024.0 * 1024.0); - samples.add(new Utils.MemorySample(System.currentTimeMillis(), heapDelta, 0)); - - try { - Thread.sleep(SAMPLING_INTERVAL_MS); - } catch (InterruptedException e) { - break; - } - } - }); - - // Run operation - try { - runItemEncryptorCycle(data); - } catch (Exception e) { - System.out.printf("Iteration %d failed: %s%n", i + 1, e.getMessage()); - continue; + if (iterationResult.peakMemory > peakMemoryDelta) { + peakMemoryDelta = iterationResult.peakMemory; } + if (iterationResult.totalAllocs > peakAllocations) { + peakAllocations = iterationResult.totalAllocs; + } + avgMemoryValues.add(iterationResult.avgMemory); + } - // Stop sampling - samplingTask.cancel(true); - Thread.sleep(FINAL_SAMPLE_WAIT_MS); + double overallAvgMemory = avgMemoryValues.isEmpty() ? 0.0 : + avgMemoryValues.stream().mapToDouble(Double::doubleValue).average().orElse(0.0); + + System.out.println("\nMemory Summary:"); + System.out.printf("- Absolute Peak Heap: %.2f MB (across all runs)%n", peakMemoryDelta); + System.out.printf("- Average Heap: %.2f MB (across all runs)%n", overallAvgMemory); + System.out.printf("- Total Allocations: %.2f MB (max across all runs)%n", peakAllocations); + System.out.flush(); + + return new MemoryResults(peakMemoryDelta, overallAvgMemory); + } + + /** + * Runs a single memory iteration with enhanced sampling. + */ + private IterationResult runSingleMemoryIteration(byte[] data, int iteration) { + // Force GC and settle (matching ESDK approach) + System.gc(); + System.gc(); + try { + Thread.sleep(GC_SETTLE_TIME_MS); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException("Memory test interrupted during GC settle phase", e); + } - // Analyze samples - if (!samples.isEmpty()) { - double iterPeakHeap = samples.stream() - .mapToDouble(Utils.MemorySample::getHeapMb) - .max().orElse(0.0); - double iterAvgHeap = samples.stream() - .mapToDouble(Utils.MemorySample::getHeapMb) - .average().orElse(0.0); + long baselineMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + long baselineAllocations = getTotalAllocatedBytes(); + List memorySamples = new ArrayList<>(); - peakMemoryMb = Math.max(peakMemoryMb, iterPeakHeap); - avgMemoryValues.add(iterAvgHeap); + long operationStart = System.nanoTime(); - System.out.printf("=== Iteration %d === Peak Heap: %.2f MB, Avg Heap: %.2f MB (%d samples)%n", - i + 1, iterPeakHeap, iterAvgHeap, samples.size()); + // Start background sampling + Thread samplingTask = new Thread(() -> { + try { + while (System.nanoTime() - operationStart < 100_000_000) { // 100ms max + long currentMemory = Runtime.getRuntime().totalMemory() - + Runtime.getRuntime().freeMemory(); + long currentAllocations = getTotalAllocatedBytes(); + double heapDelta = (currentMemory - baselineMemory) / (1024.0 * 1024.0); + double cumulativeAllocs = (currentAllocations - baselineAllocations) / (1024.0 * 1024.0); + + if (heapDelta > 0 || cumulativeAllocs > 0) { + synchronized (memorySamples) { + memorySamples.add(new EnhancedMemorySample( + Math.max(0, heapDelta), + Math.max(0, cumulativeAllocs) + )); + } + } + Thread.sleep(SAMPLING_INTERVAL_MS); + } + } catch (InterruptedException e) { + // Expected when operation completes } + }); + + samplingTask.start(); + + // Run the actual operation + try { + runItemEncryptorCycle(data); + } catch (Exception e) { + System.out.printf("Memory test iteration %d failed: %s%n", iteration, e.getMessage()); + return new IterationResult(0.0, 0.0, 0.0); } - if (avgMemoryValues.isEmpty()) { - throw new Exception("All memory test iterations failed"); + double operationDurationMs = (System.nanoTime() - operationStart) / 1_000_000.0; + + // Wait for sampling to complete + try { + Thread.sleep(FINAL_SAMPLE_WAIT_MS); + samplingTask.join(100); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } - double overallAvgHeap = Utils.average(avgMemoryValues); - double memoryEfficiency = overallAvgHeap > 0 ? dataSize / (overallAvgHeap * 1024 * 1024) : 0.0; + return calculateIterationMetrics( + baselineMemory, + baselineAllocations, + memorySamples, + iteration, + operationDurationMs + ); + } - System.out.printf("\nMemory Summary:%n"); - System.out.printf("- Absolute Peak Heap: %.2f MB (across all runs)%n", peakMemoryMb); - System.out.printf("- Average Heap: %.2f MB (across all runs)%n", overallAvgHeap); + /** + * Calculates comprehensive metrics for a single iteration. + */ + private IterationResult calculateIterationMetrics( + long baselineMemory, + long baselineAllocations, + List memorySamples, + int iteration, + double operationDurationMs + ) { + long finalMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + long finalAllocations = getTotalAllocatedBytes(); + double finalHeapDelta = (finalMemory - baselineMemory) / (1024.0 * 1024.0); + double finalCumulativeAllocs = (finalAllocations - baselineAllocations) / (1024.0 * 1024.0); + + double iterPeakMemory; + double iterTotalAllocs; + double iterAvgMemory; + + synchronized (memorySamples) { + if (memorySamples.isEmpty()) { + iterPeakMemory = Math.max(0, finalHeapDelta); + iterTotalAllocs = Math.max(0, finalCumulativeAllocs); + iterAvgMemory = Math.max(0, finalHeapDelta); + } else { + iterPeakMemory = memorySamples.stream().mapToDouble(s -> s.heapMB).max().orElse(0.0); + iterTotalAllocs = Math.max(0, finalCumulativeAllocs); + iterAvgMemory = memorySamples.stream().mapToDouble(s -> s.heapMB).average().orElse(0.0); + } + } - BenchmarkResult result = new BenchmarkResult("memory", "java", dataSize, 1); - result.setPeakMemoryMb(peakMemoryMb); - result.setMemoryEfficiencyRatio(memoryEfficiency); - result.setTimestamp(Utils.getCurrentTimestamp()); - result.setJavaVersion(Utils.getJavaVersion()); - result.setCpuCount(cpuCount); - result.setTotalMemoryGb(totalMemoryGb); + System.out.printf("=== Iteration %d === Peak Heap: %.2f MB, Total Allocs: %.2f MB, " + + "Avg Heap: %.2f MB (%.0fms, %d samples)%n", + iteration, iterPeakMemory, iterTotalAllocs, iterAvgMemory, + operationDurationMs, memorySamples.size()); + System.out.flush(); - return result; + return new IterationResult(iterPeakMemory, iterTotalAllocs, iterAvgMemory); } /** @@ -485,4 +588,11 @@ private static class LatencyResult { this.getLatencyMs = getLatencyMs; } } + + // Helper records for enhanced memory testing + private record IterationResult(double peakMemory, double totalAllocs, double avgMemory) {} + + private record MemoryResults(double peakMemoryMb, double avgMemoryMb) {} + + private record EnhancedMemorySample(double heapMB, double allocsMB) {} } diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java index f68a48ba7f..aed7c11899 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java @@ -9,6 +9,7 @@ import software.amazon.cryptography.materialproviders.model.CreateRawAesKeyringInput; import software.amazon.cryptography.materialproviders.model.MaterialProvidersConfig; +import java.nio.ByteBuffer; import java.security.SecureRandom; import java.util.Map; @@ -55,7 +56,7 @@ private static IKeyring createRawAesKeyring() throws Exception { CreateRawAesKeyringInput keyringInput = CreateRawAesKeyringInput.builder() .keyName("test-aes-256-key") .keyNamespace("DB-ESDK-performance-test") - .wrappingKey(key) + .wrappingKey(ByteBuffer.wrap(key)) .wrappingAlg(AesWrappingAlg.ALG_AES256_GCM_IV12_TAG16) .build(); diff --git a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json new file mode 100644 index 0000000000..76e551d852 --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json @@ -0,0 +1,68 @@ +{ + "metadata" : { + "total_memory_gb" : 12.0, + "java_version" : "17.0.16", + "language" : "java", + "total_tests" : 3, + "timestamp" : "2026-01-21 13:01:52", + "cpu_count" : 14 + }, + "results" : [ { + "test_name" : "throughput", + "language" : "java", + "data_size" : 102400, + "concurrency" : 1, + "put_latency_ms" : 5.614888666666666, + "get_latency_ms" : 5.1142639999999995, + "end_to_end_latency_ms" : 10.820486333333333, + "ops_per_second" : 92.39333382096481, + "bytes_per_second" : 9461077.383266797, + "peak_memory_mb" : 0.0, + "memory_efficiency_ratio" : 0.0, + "p50_latency" : 10.601417, + "p95_latency" : 11.297454499999999, + "p99_latency" : 11.3593245, + "timestamp" : "2026-01-21 13:01:52", + "java_version" : "17.0.16", + "cpu_count" : 14, + "total_memory_gb" : 12.0 + }, { + "test_name" : "memory", + "language" : "java", + "data_size" : 102400, + "concurrency" : 1, + "put_latency_ms" : 0.0, + "get_latency_ms" : 0.0, + "end_to_end_latency_ms" : 0.0, + "ops_per_second" : 0.0, + "bytes_per_second" : 0.0, + "peak_memory_mb" : 4.139717102050781, + "memory_efficiency_ratio" : 0.023590078160563657, + "p50_latency" : 0.0, + "p95_latency" : 0.0, + "p99_latency" : 0.0, + "timestamp" : "2026-01-21 13:01:52", + "java_version" : "17.0.16", + "cpu_count" : 14, + "total_memory_gb" : 12.0 + }, { + "test_name" : "concurrent", + "language" : "java", + "data_size" : 102400, + "concurrency" : 2, + "put_latency_ms" : 0.0, + "get_latency_ms" : 0.0, + "end_to_end_latency_ms" : 10.5485459, + "ops_per_second" : 183.32981951179266, + "bytes_per_second" : 1.877297351800757E7, + "peak_memory_mb" : 0.0, + "memory_efficiency_ratio" : 0.0, + "p50_latency" : 10.253563, + "p95_latency" : 12.205531099999998, + "p99_latency" : 12.23560622, + "timestamp" : "2026-01-21 13:01:52", + "java_version" : "17.0.16", + "cpu_count" : 14, + "total_memory_gb" : 12.0 + } ] +} \ No newline at end of file From 91ea1faef587ff27bfa6c820c8ec361dba97c7ba Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 13:26:19 -0800 Subject: [PATCH 05/12] add to workflow --- .../workflows/performance-benchmarks-java.yml | 131 ++ .github/workflows/performance-benchmarks.yml | 7 +- .../benchmarks/java/README.md | 17 +- .../dbesdk/benchmark/BenchmarkResult.java | 349 +++-- .../dbesdk/benchmark/DBESDKBenchmark.java | 1210 +++++++++-------- .../amazon/dbesdk/benchmark/KeyringSetup.java | 91 +- .../com/amazon/dbesdk/benchmark/Program.java | 456 ++++--- .../amazon/dbesdk/benchmark/TestConfig.java | 454 ++++--- .../com/amazon/dbesdk/benchmark/Utils.java | 393 +++--- .../results/raw-data/java_results.json | 136 +- 10 files changed, 1909 insertions(+), 1335 deletions(-) create mode 100644 .github/workflows/performance-benchmarks-java.yml diff --git a/.github/workflows/performance-benchmarks-java.yml b/.github/workflows/performance-benchmarks-java.yml new file mode 100644 index 0000000000..1e46775856 --- /dev/null +++ b/.github/workflows/performance-benchmarks-java.yml @@ -0,0 +1,131 @@ +# This workflow runs every day 09:00 UTC (1AM PST) +name: Performance Benchmarks + +on: + workflow_call: + inputs: + dafny: + description: "The Dafny version to run" + required: false + default: "4.9.0" + type: string + regenerate-code: + description: "Regenerate code using smithy-dafny" + required: false + default: false + type: boolean + mpl-version: + description: "MPL version to use" + required: false + type: string + mpl-head: + description: "Running on MPL HEAD" + required: false + default: false + type: boolean +jobs: + testGo: + strategy: + fail-fast: false + matrix: + library: [DynamoDbEncryption] + benchmark-dir: [db-esdk-performance-testing] + java-version: [8] + os: [macos-14] + runs-on: ${{ matrix.os }} + permissions: + id-token: write + contents: read + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v5 + with: + aws-region: us-west-2 + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2 + role-session-name: DDBEC-Performance-Benchmarks-Java + + - uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Setup Dafny + uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/ + with: + dafny-version: ${{ inputs.dafny }} + + - name: Update MPL submodule if using MPL HEAD + if: ${{ inputs.mpl-head == true }} + working-directory: submodules/MaterialProviders + run: | + git checkout main + git pull + git submodule update --init --recursive + git rev-parse HEAD + + - name: Update project.properties if using MPL HEAD + if: ${{ inputs.mpl-head == true }} + run: | + sed "s/mplDependencyJavaVersion=.*/mplDependencyJavaVersion=${{inputs.mpl-version}}/g" project.properties > project.properties2; mv project.properties2 project.properties + + - name: Install Smithy-Dafny codegen dependencies + uses: ./.github/actions/install_smithy_dafny_codegen_dependencies + + - name: Regenerate code using smithy-dafny if necessary + if: ${{ inputs.regenerate-code }} + uses: ./.github/actions/polymorph_codegen + with: + dafny: ${{ env.DAFNY_VERSION }} + library: ${{ matrix.library }} + diff-generated-code: false + update-and-regenerate-mpl: true + + - name: Setup Java 8 + uses: actions/setup-java@v5 + with: + distribution: "corretto" + java-version: 8 + + - name: Setup Java ${{ matrix.java-version }} + uses: actions/setup-java@v5 + with: + distribution: "corretto" + java-version: ${{ matrix.java-version }} + + - name: Build ${{ matrix.library }} implementation + shell: bash + working-directory: ./${{ matrix.library }} + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make build_java CORES=$CORES + + - name: Run Performance Benchmarks - Quick Mode + shell: bash + working-directory: ./${{matrix.benchmark-dir}}/benchmarks/java + run: | + ./gradlew run --args="--config ../config/test-scenarios.yaml --quick" + + - name: Parse and Format Logs + working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/ + run: | + LOG_FILE="java_results.json" + UPLOAD_FILE="cloudwatch_logs.json" + TIMESTAMP=$(date +%s%3N) + jq -c --arg ts "$(date +%s)000" '[.results[] as $result | .metadata as $meta | {timestamp: ($ts | tonumber), message: ({metadata: $meta, result: $result} | tostring)}]' $LOG_FILE > $UPLOAD_FILE + + - name: Upload logs to CloudWatch + working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/ + run: | + LOG_FILE="cloudwatch_logs.json" + LOG_GROUP="aws-dbesdk-performance-benchmarks" + LOG_STREAM="java/${{matrix.java-version}}/quick_benchmarks/${{ github.workflow }}" + + # Create log stream (ignore if exists) + aws logs create-log-stream \ + --log-group-name "$LOG_GROUP" \ + --log-stream-name "$LOG_STREAM" 2>/dev/null || true + + aws logs put-log-events \ + --log-group-name "$LOG_GROUP" \ + --log-stream-name "$LOG_STREAM" \ + --log-events file://$LOG_FILE diff --git a/.github/workflows/performance-benchmarks.yml b/.github/workflows/performance-benchmarks.yml index 671250b816..4382d81b67 100644 --- a/.github/workflows/performance-benchmarks.yml +++ b/.github/workflows/performance-benchmarks.yml @@ -21,8 +21,13 @@ jobs: uses: ./.github/workflows/performance-benchmarks-go.yml with: dafny: ${{needs.getVersion.outputs.version}} + performance-benchmarks-java: + needs: getVersion + uses: ./.github/workflows/performance-benchmarks-java.yml + with: + dafny: ${{needs.getVersion.outputs.version}} notify: - needs: [getVersion, performance-benchmarks-go] + needs: [getVersion, performance-benchmarks-go, performance-benchmarks-java] if: ${{ failure() }} uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main with: diff --git a/db-esdk-performance-testing/benchmarks/java/README.md b/db-esdk-performance-testing/benchmarks/java/README.md index e0987ad95a..e38c4bcc96 100644 --- a/db-esdk-performance-testing/benchmarks/java/README.md +++ b/db-esdk-performance-testing/benchmarks/java/README.md @@ -45,13 +45,13 @@ Quick mode runs a subset of tests with reduced iterations: ```yaml # Data sizes to test (in bytes) data_sizes: - small: [1024, 5120, 10240] # 1KB, 5KB, 10KB - medium: [102400, 512000, 1048576] # 100KB, 500KB, 1MB - large: [10485760, 52428800, 104857600] # 10MB, 50MB, 100MB + small: [1024, 5120, 10240] # 1KB, 5KB, 10KB + medium: [102400, 512000, 1048576] # 100KB, 500KB, 1MB + large: [10485760, 52428800, 104857600] # 10MB, 50MB, 100MB # Test iterations iterations: - warmup: 5 # Warmup iterations (not counted) + warmup: 5 # Warmup iterations (not counted) measurement: 10 # Measurement iterations # Concurrency levels to test @@ -66,7 +66,7 @@ keyring: "raw-aes" # Quick test configuration quick_config: data_sizes: - small: [102400] # 100KB only for quick mode + small: [102400] # 100KB only for quick mode iterations: warmup: 3 measurement: 3 @@ -157,7 +157,7 @@ The benchmark tests encryption of DynamoDB items with this structure: ```java { "partition_key": "benchmark-test", // SIGN_ONLY - "sort_key": "0", // SIGN_ONLY + "sort_key": "0", // SIGN_ONLY "attribute1": { // ENCRYPT_AND_SIGN "data": }, @@ -169,7 +169,7 @@ The benchmark tests encryption of DynamoDB items with this structure: ## Dependencies - **AWS Database Encryption SDK for DynamoDB**: Core encryption functionality -- **AWS Cryptographic Material Providers Library**: Keyring management +- **AWS Cryptographic Material Providers Library**: Keyring management - **AWS SDK for Java v2**: DynamoDB types and utilities - **SnakeYAML**: Configuration file parsing - **Jackson**: JSON output formatting @@ -187,7 +187,7 @@ The benchmark tests encryption of DynamoDB items with this structure: The Java implementation provides identical functionality to the Go version: - **Same test types**: throughput, memory, concurrency -- **Same data sizes**: 1KB to 100MB range +- **Same data sizes**: 1KB to 100MB range - **Same configuration format**: YAML with quick mode support - **Same output format**: JSON with matching field names and structure - **Same keyring setup**: Raw AES-256 keyring with random key generation @@ -216,3 +216,4 @@ The Java implementation provides identical functionality to the Go version: # Build standalone JAR and run ./gradlew fatJar java -Xmx4g -jar build/libs/db-esdk-benchmark-java-1.0.0-all.jar --quick +``` diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java index b062f86506..f5f69f988c 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/BenchmarkResult.java @@ -10,128 +10,229 @@ * Fields match the Go implementation exactly for compatibility. */ public class BenchmarkResult { - @JsonProperty("test_name") - private String testName; - - @JsonProperty("language") - private String language; - - @JsonProperty("data_size") - private int dataSize; - - @JsonProperty("concurrency") - private int concurrency; - - @JsonProperty("put_latency_ms") - private double putLatencyMs; - - @JsonProperty("get_latency_ms") - private double getLatencyMs; - - @JsonProperty("end_to_end_latency_ms") - private double endToEndLatencyMs; - - @JsonProperty("ops_per_second") - private double opsPerSecond; - - @JsonProperty("bytes_per_second") - private double bytesPerSecond; - - @JsonProperty("peak_memory_mb") - private double peakMemoryMb; - - @JsonProperty("memory_efficiency_ratio") - private double memoryEfficiencyRatio; - - @JsonProperty("p50_latency") - private double p50Latency; - - @JsonProperty("p95_latency") - private double p95Latency; - - @JsonProperty("p99_latency") - private double p99Latency; - - @JsonProperty("timestamp") - private String timestamp; - - @JsonProperty("java_version") - private String javaVersion; - - @JsonProperty("cpu_count") - private int cpuCount; - - @JsonProperty("total_memory_gb") - private double totalMemoryGb; - - // Constructors - public BenchmarkResult() {} - - public BenchmarkResult(String testName, String language, int dataSize, int concurrency) { - this.testName = testName; - this.language = language; - this.dataSize = dataSize; - this.concurrency = concurrency; - } - - // Getters and Setters - public String getTestName() { return testName; } - public void setTestName(String testName) { this.testName = testName; } - - public String getLanguage() { return language; } - public void setLanguage(String language) { this.language = language; } - - public int getDataSize() { return dataSize; } - public void setDataSize(int dataSize) { this.dataSize = dataSize; } - - public int getConcurrency() { return concurrency; } - public void setConcurrency(int concurrency) { this.concurrency = concurrency; } - - public double getPutLatencyMs() { return putLatencyMs; } - public void setPutLatencyMs(double putLatencyMs) { this.putLatencyMs = putLatencyMs; } - - public double getGetLatencyMs() { return getLatencyMs; } - public void setGetLatencyMs(double getLatencyMs) { this.getLatencyMs = getLatencyMs; } - - public double getEndToEndLatencyMs() { return endToEndLatencyMs; } - public void setEndToEndLatencyMs(double endToEndLatencyMs) { this.endToEndLatencyMs = endToEndLatencyMs; } - - public double getOpsPerSecond() { return opsPerSecond; } - public void setOpsPerSecond(double opsPerSecond) { this.opsPerSecond = opsPerSecond; } - - public double getBytesPerSecond() { return bytesPerSecond; } - public void setBytesPerSecond(double bytesPerSecond) { this.bytesPerSecond = bytesPerSecond; } - - public double getPeakMemoryMb() { return peakMemoryMb; } - public void setPeakMemoryMb(double peakMemoryMb) { this.peakMemoryMb = peakMemoryMb; } - - public double getMemoryEfficiencyRatio() { return memoryEfficiencyRatio; } - public void setMemoryEfficiencyRatio(double memoryEfficiencyRatio) { this.memoryEfficiencyRatio = memoryEfficiencyRatio; } - - public double getP50Latency() { return p50Latency; } - public void setP50Latency(double p50Latency) { this.p50Latency = p50Latency; } - - public double getP95Latency() { return p95Latency; } - public void setP95Latency(double p95Latency) { this.p95Latency = p95Latency; } - - public double getP99Latency() { return p99Latency; } - public void setP99Latency(double p99Latency) { this.p99Latency = p99Latency; } - - public String getTimestamp() { return timestamp; } - public void setTimestamp(String timestamp) { this.timestamp = timestamp; } - - public String getJavaVersion() { return javaVersion; } - public void setJavaVersion(String javaVersion) { this.javaVersion = javaVersion; } - - public int getCpuCount() { return cpuCount; } - public void setCpuCount(int cpuCount) { this.cpuCount = cpuCount; } - - public double getTotalMemoryGb() { return totalMemoryGb; } - public void setTotalMemoryGb(double totalMemoryGb) { this.totalMemoryGb = totalMemoryGb; } - - @Override - public String toString() { - return String.format("BenchmarkResult{testName='%s', dataSize=%d, concurrency=%d, opsPerSecond=%.2f}", - testName, dataSize, concurrency, opsPerSecond); - } + + @JsonProperty("test_name") + private String testName; + + @JsonProperty("language") + private String language; + + @JsonProperty("data_size") + private int dataSize; + + @JsonProperty("concurrency") + private int concurrency; + + @JsonProperty("put_latency_ms") + private double putLatencyMs; + + @JsonProperty("get_latency_ms") + private double getLatencyMs; + + @JsonProperty("end_to_end_latency_ms") + private double endToEndLatencyMs; + + @JsonProperty("ops_per_second") + private double opsPerSecond; + + @JsonProperty("bytes_per_second") + private double bytesPerSecond; + + @JsonProperty("peak_memory_mb") + private double peakMemoryMb; + + @JsonProperty("memory_efficiency_ratio") + private double memoryEfficiencyRatio; + + @JsonProperty("p50_latency") + private double p50Latency; + + @JsonProperty("p95_latency") + private double p95Latency; + + @JsonProperty("p99_latency") + private double p99Latency; + + @JsonProperty("timestamp") + private String timestamp; + + @JsonProperty("java_version") + private String javaVersion; + + @JsonProperty("cpu_count") + private int cpuCount; + + @JsonProperty("total_memory_gb") + private double totalMemoryGb; + + // Constructors + public BenchmarkResult() {} + + public BenchmarkResult( + String testName, + String language, + int dataSize, + int concurrency + ) { + this.testName = testName; + this.language = language; + this.dataSize = dataSize; + this.concurrency = concurrency; + } + + // Getters and Setters + public String getTestName() { + return testName; + } + + public void setTestName(String testName) { + this.testName = testName; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public int getDataSize() { + return dataSize; + } + + public void setDataSize(int dataSize) { + this.dataSize = dataSize; + } + + public int getConcurrency() { + return concurrency; + } + + public void setConcurrency(int concurrency) { + this.concurrency = concurrency; + } + + public double getPutLatencyMs() { + return putLatencyMs; + } + + public void setPutLatencyMs(double putLatencyMs) { + this.putLatencyMs = putLatencyMs; + } + + public double getGetLatencyMs() { + return getLatencyMs; + } + + public void setGetLatencyMs(double getLatencyMs) { + this.getLatencyMs = getLatencyMs; + } + + public double getEndToEndLatencyMs() { + return endToEndLatencyMs; + } + + public void setEndToEndLatencyMs(double endToEndLatencyMs) { + this.endToEndLatencyMs = endToEndLatencyMs; + } + + public double getOpsPerSecond() { + return opsPerSecond; + } + + public void setOpsPerSecond(double opsPerSecond) { + this.opsPerSecond = opsPerSecond; + } + + public double getBytesPerSecond() { + return bytesPerSecond; + } + + public void setBytesPerSecond(double bytesPerSecond) { + this.bytesPerSecond = bytesPerSecond; + } + + public double getPeakMemoryMb() { + return peakMemoryMb; + } + + public void setPeakMemoryMb(double peakMemoryMb) { + this.peakMemoryMb = peakMemoryMb; + } + + public double getMemoryEfficiencyRatio() { + return memoryEfficiencyRatio; + } + + public void setMemoryEfficiencyRatio(double memoryEfficiencyRatio) { + this.memoryEfficiencyRatio = memoryEfficiencyRatio; + } + + public double getP50Latency() { + return p50Latency; + } + + public void setP50Latency(double p50Latency) { + this.p50Latency = p50Latency; + } + + public double getP95Latency() { + return p95Latency; + } + + public void setP95Latency(double p95Latency) { + this.p95Latency = p95Latency; + } + + public double getP99Latency() { + return p99Latency; + } + + public void setP99Latency(double p99Latency) { + this.p99Latency = p99Latency; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getJavaVersion() { + return javaVersion; + } + + public void setJavaVersion(String javaVersion) { + this.javaVersion = javaVersion; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public double getTotalMemoryGb() { + return totalMemoryGb; + } + + public void setTotalMemoryGb(double totalMemoryGb) { + this.totalMemoryGb = totalMemoryGb; + } + + @Override + public String toString() { + return String.format( + "BenchmarkResult{testName='%s', dataSize=%d, concurrency=%d, opsPerSecond=%.2f}", + testName, + dataSize, + concurrency, + opsPerSecond + ); + } } diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java index effe5f9233..dc020eddcc 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java @@ -4,18 +4,6 @@ package com.amazon.dbesdk.benchmark; import com.fasterxml.jackson.databind.ObjectMapper; -import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.DynamoDbItemEncryptor; -import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DecryptItemInput; -import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DecryptItemOutput; -import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DynamoDbItemEncryptorConfig; -import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemInput; -import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemOutput; -import software.amazon.cryptography.dbencryptionsdk.structuredencryption.model.CryptoAction; -import software.amazon.cryptography.materialproviders.IKeyring; -import software.amazon.cryptography.materialproviders.model.DBEAlgorithmSuiteId; -import software.amazon.awssdk.core.SdkBytes; -import software.amazon.awssdk.services.dynamodb.model.AttributeValue; - import java.io.File; import java.io.IOException; import java.lang.management.ManagementFactory; @@ -28,571 +16,729 @@ import java.util.concurrent.*; import java.util.stream.Collectors; import java.util.stream.Stream; +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.DynamoDbItemEncryptor; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DecryptItemInput; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DecryptItemOutput; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DynamoDbItemEncryptorConfig; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemInput; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemOutput; +import software.amazon.cryptography.dbencryptionsdk.structuredencryption.model.CryptoAction; +import software.amazon.cryptography.materialproviders.IKeyring; +import software.amazon.cryptography.materialproviders.model.DBEAlgorithmSuiteId; /** * Main DB-ESDK benchmark class that orchestrates performance testing. */ public class DBESDKBenchmark { - - private static final int MEMORY_TEST_ITERATIONS = 5; - private static final int SAMPLING_INTERVAL_MS = 1; - private static final int GC_SETTLE_TIME_MS = 5; - private static final int FINAL_SAMPLE_WAIT_MS = 2; - - private final TestConfig config; - private final IKeyring keyring; - private final DynamoDbItemEncryptor itemEncryptor; - private final List results; - private final int cpuCount; - private final double totalMemoryGb; - - /** - * Creates a new benchmark instance. - * - * @param configPath Path to the YAML configuration file - * @throws Exception if initialization fails - */ - public DBESDKBenchmark(String configPath) throws Exception { - this.config = TestConfig.loadConfig(configPath); - this.results = new ArrayList<>(); - this.cpuCount = Utils.getCpuCount(); - this.totalMemoryGb = Utils.getTotalMemoryGb(); - - // Initialize keyring - this.keyring = KeyringSetup.createKeyring(config.getKeyring()); - - // Initialize item encryptor - this.itemEncryptor = setupItemEncryptor(); - - System.out.printf("Initialized DB-ESDK Benchmark - CPU cores: %d, Memory: %.1f GB%n", - cpuCount, totalMemoryGb); - } - /** - * Sets up the DynamoDB Item Encryptor with proper configuration. - */ - private DynamoDbItemEncryptor setupItemEncryptor() throws Exception { - // Define attribute actions (matching Go implementation) - Map attributeActions = new HashMap<>(); - attributeActions.put("partition_key", CryptoAction.SIGN_ONLY); - attributeActions.put("sort_key", CryptoAction.SIGN_ONLY); - attributeActions.put("attribute1", CryptoAction.ENCRYPT_AND_SIGN); - attributeActions.put("attribute2", CryptoAction.SIGN_ONLY); - attributeActions.put(":attribute3", CryptoAction.DO_NOTHING); - - String allowedUnsignedAttributePrefix = ":"; - DBEAlgorithmSuiteId algorithmSuiteId = DBEAlgorithmSuiteId.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384_SYMSIG_HMAC_SHA384; - - DynamoDbItemEncryptorConfig itemEncryptorConfig = DynamoDbItemEncryptorConfig.builder() - .logicalTableName(config.getTableName()) - .partitionKeyName("partition_key") - .sortKeyName("sort_key") - .attributeActionsOnEncrypt(attributeActions) - .keyring(keyring) - .allowedUnsignedAttributePrefix(allowedUnsignedAttributePrefix) - .algorithmSuiteId(algorithmSuiteId) - .build(); - - return DynamoDbItemEncryptor.builder() - .DynamoDbItemEncryptorConfig(itemEncryptorConfig) - .build(); + private static final int MEMORY_TEST_ITERATIONS = 5; + private static final int SAMPLING_INTERVAL_MS = 1; + private static final int GC_SETTLE_TIME_MS = 5; + private static final int FINAL_SAMPLE_WAIT_MS = 2; + + private final TestConfig config; + private final IKeyring keyring; + private final DynamoDbItemEncryptor itemEncryptor; + private final List results; + private final int cpuCount; + private final double totalMemoryGb; + + /** + * Creates a new benchmark instance. + * + * @param configPath Path to the YAML configuration file + * @throws Exception if initialization fails + */ + public DBESDKBenchmark(String configPath) throws Exception { + this.config = TestConfig.loadConfig(configPath); + this.results = new ArrayList<>(); + this.cpuCount = Utils.getCpuCount(); + this.totalMemoryGb = Utils.getTotalMemoryGb(); + + // Initialize keyring + this.keyring = KeyringSetup.createKeyring(config.getKeyring()); + + // Initialize item encryptor + this.itemEncryptor = setupItemEncryptor(); + + System.out.printf( + "Initialized DB-ESDK Benchmark - CPU cores: %d, Memory: %.1f GB%n", + cpuCount, + totalMemoryGb + ); + } + + /** + * Sets up the DynamoDB Item Encryptor with proper configuration. + */ + private DynamoDbItemEncryptor setupItemEncryptor() throws Exception { + // Define attribute actions (matching Go implementation) + Map attributeActions = new HashMap<>(); + attributeActions.put("partition_key", CryptoAction.SIGN_ONLY); + attributeActions.put("sort_key", CryptoAction.SIGN_ONLY); + attributeActions.put("attribute1", CryptoAction.ENCRYPT_AND_SIGN); + attributeActions.put("attribute2", CryptoAction.SIGN_ONLY); + attributeActions.put(":attribute3", CryptoAction.DO_NOTHING); + + String allowedUnsignedAttributePrefix = ":"; + DBEAlgorithmSuiteId algorithmSuiteId = + DBEAlgorithmSuiteId.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384_SYMSIG_HMAC_SHA384; + + DynamoDbItemEncryptorConfig itemEncryptorConfig = + DynamoDbItemEncryptorConfig + .builder() + .logicalTableName(config.getTableName()) + .partitionKeyName("partition_key") + .sortKeyName("sort_key") + .attributeActionsOnEncrypt(attributeActions) + .keyring(keyring) + .allowedUnsignedAttributePrefix(allowedUnsignedAttributePrefix) + .algorithmSuiteId(algorithmSuiteId) + .build(); + + return DynamoDbItemEncryptor + .builder() + .DynamoDbItemEncryptorConfig(itemEncryptorConfig) + .build(); + } + + /** + * Runs all configured benchmark tests. + */ + public List runAllBenchmarks() throws Exception { + System.out.println("Starting comprehensive DB-ESDK benchmark suite"); + + // Combine all data sizes + List allDataSizes = Stream + .of( + config.getDataSizes().getSmall(), + config.getDataSizes().getMedium(), + config.getDataSizes().getLarge() + ) + .filter(Objects::nonNull) + .flatMap(List::stream) + .collect(Collectors.toList()); + + // Get allowed test types from quick config if available + List allowedTestTypes = config.getQuickConfig() != null + ? config.getQuickConfig().getTestTypes() + : null; + + // Run test suites + if (Utils.shouldRunTestType("throughput", allowedTestTypes)) { + runThroughputTests(allDataSizes, config.getIterations().getMeasurement()); + } else { + System.out.println("Skipping throughput tests (not in test_types)"); } - /** - * Runs all configured benchmark tests. - */ - public List runAllBenchmarks() throws Exception { - System.out.println("Starting comprehensive DB-ESDK benchmark suite"); - - // Combine all data sizes - List allDataSizes = Stream.of( - config.getDataSizes().getSmall(), - config.getDataSizes().getMedium(), - config.getDataSizes().getLarge() - ).filter(Objects::nonNull) - .flatMap(List::stream) - .collect(Collectors.toList()); - - // Get allowed test types from quick config if available - List allowedTestTypes = config.getQuickConfig() != null ? - config.getQuickConfig().getTestTypes() : null; - - // Run test suites - if (Utils.shouldRunTestType("throughput", allowedTestTypes)) { - runThroughputTests(allDataSizes, config.getIterations().getMeasurement()); - } else { - System.out.println("Skipping throughput tests (not in test_types)"); - } - - if (Utils.shouldRunTestType("memory", allowedTestTypes)) { - runMemoryTests(allDataSizes); - } else { - System.out.println("Skipping memory tests (not in test_types)"); - } - - if (Utils.shouldRunTestType("concurrency", allowedTestTypes)) { - runConcurrencyTests(allDataSizes, config.getConcurrencyLevels()); - } else { - System.out.println("Skipping concurrency tests (not in test_types)"); - } - - System.out.printf("Benchmark suite completed. Total results: %d%n", results.size()); - return results; + if (Utils.shouldRunTestType("memory", allowedTestTypes)) { + runMemoryTests(allDataSizes); + } else { + System.out.println("Skipping memory tests (not in test_types)"); } - /** - * Runs throughput benchmark tests. - */ - private void runThroughputTests(List dataSizes, int iterations) throws Exception { - System.out.println("Running throughput tests..."); - for (int dataSize : dataSizes) { - BenchmarkResult result = runThroughputTest(dataSize, iterations); - if (result != null) { - results.add(result); - System.out.printf("Throughput test completed: %.2f ops/sec%n", result.getOpsPerSecond()); - } - } + if (Utils.shouldRunTestType("concurrency", allowedTestTypes)) { + runConcurrencyTests(allDataSizes, config.getConcurrencyLevels()); + } else { + System.out.println("Skipping concurrency tests (not in test_types)"); } - /** - * Runs a single throughput test. - */ - private BenchmarkResult runThroughputTest(int dataSize, int iterations) throws Exception { - System.out.printf("Running throughput test - Size: %d bytes, Iterations: %d%n", dataSize, iterations); - - byte[] testData = Utils.generateTestData(dataSize); - - // Warmup - for (int i = 0; i < config.getIterations().getWarmup(); i++) { - runItemEncryptorCycle(testData); - } - - // Measurement runs - List putLatencies = new ArrayList<>(); - List getLatencies = new ArrayList<>(); - List endToEndLatencies = new ArrayList<>(); - long totalBytes = 0; - - long startTime = System.nanoTime(); - for (int i = 0; i < iterations; i++) { - long iterationStart = System.nanoTime(); - - LatencyResult latencyResult = runItemEncryptorCycle(testData); - - long iterationDuration = System.nanoTime() - iterationStart; - double iterationMs = Utils.nanosToMillis(iterationDuration); - - putLatencies.add(latencyResult.putLatencyMs); - getLatencies.add(latencyResult.getLatencyMs); - endToEndLatencies.add(iterationMs); - totalBytes += dataSize; - } - double totalDuration = Utils.nanosToMillis(System.nanoTime() - startTime) / 1000.0; // Convert to seconds - - // Calculate metrics - double[] endToEndArray = endToEndLatencies.stream().mapToDouble(Double::doubleValue).toArray(); - Arrays.sort(endToEndArray); - - BenchmarkResult result = new BenchmarkResult("throughput", "java", dataSize, 1); - result.setPutLatencyMs(Utils.average(putLatencies)); - result.setGetLatencyMs(Utils.average(getLatencies)); - result.setEndToEndLatencyMs(Utils.average(endToEndLatencies)); - result.setOpsPerSecond(iterations / totalDuration); - result.setBytesPerSecond(totalBytes / totalDuration); - result.setP50Latency(Utils.percentile(endToEndArray, 0.50)); - result.setP95Latency(Utils.percentile(endToEndArray, 0.95)); - result.setP99Latency(Utils.percentile(endToEndArray, 0.99)); - result.setTimestamp(Utils.getCurrentTimestamp()); - result.setJavaVersion(Utils.getJavaVersion()); - result.setCpuCount(cpuCount); - result.setTotalMemoryGb(totalMemoryGb); - - System.out.printf("Throughput test completed - Ops/sec: %.2f, MB/sec: %.2f%n", - result.getOpsPerSecond(), result.getBytesPerSecond() / (1024 * 1024)); - - return result; + System.out.printf( + "Benchmark suite completed. Total results: %d%n", + results.size() + ); + return results; + } + + /** + * Runs throughput benchmark tests. + */ + private void runThroughputTests(List dataSizes, int iterations) + throws Exception { + System.out.println("Running throughput tests..."); + for (int dataSize : dataSizes) { + BenchmarkResult result = runThroughputTest(dataSize, iterations); + if (result != null) { + results.add(result); + System.out.printf( + "Throughput test completed: %.2f ops/sec%n", + result.getOpsPerSecond() + ); + } } - - /** - * Runs memory benchmark tests. - */ - private void runMemoryTests(List dataSizes) throws Exception { - System.out.println("Running memory tests..."); - for (int dataSize : dataSizes) { - BenchmarkResult result = runMemoryTest(dataSize); - if (result != null) { - results.add(result); - System.out.printf("Memory test completed: %.2f MB peak%n", result.getPeakMemoryMb()); - } - } + } + + /** + * Runs a single throughput test. + */ + private BenchmarkResult runThroughputTest(int dataSize, int iterations) + throws Exception { + System.out.printf( + "Running throughput test - Size: %d bytes, Iterations: %d%n", + dataSize, + iterations + ); + + byte[] testData = Utils.generateTestData(dataSize); + + // Warmup + for (int i = 0; i < config.getIterations().getWarmup(); i++) { + runItemEncryptorCycle(testData); } - /** - * Gets the total allocated bytes for the current thread. - */ - private static long getTotalAllocatedBytes() { - final var threadBean = ManagementFactory.getThreadMXBean(); - final var sunThreadBean = (com.sun.management.ThreadMXBean) threadBean; + // Measurement runs + List putLatencies = new ArrayList<>(); + List getLatencies = new ArrayList<>(); + List endToEndLatencies = new ArrayList<>(); + long totalBytes = 0; - if (!sunThreadBean.isThreadAllocatedMemoryEnabled()) { - sunThreadBean.setThreadAllocatedMemoryEnabled(true); - } - - return sunThreadBean.getCurrentThreadAllocatedBytes(); - } + long startTime = System.nanoTime(); + for (int i = 0; i < iterations; i++) { + long iterationStart = System.nanoTime(); - /** - * Runs a single memory test with enhanced continuous monitoring. - */ - private BenchmarkResult runMemoryTest(int dataSize) throws Exception { - System.out.printf("Running memory test - Size: %d bytes (%d iterations, continuous sampling)%n", - dataSize, MEMORY_TEST_ITERATIONS); - System.out.flush(); - - byte[] data = Utils.generateTestData(dataSize); - MemoryResults memoryResults = sampleMemoryDuringOperations(data); - - if (memoryResults == null) { - throw new RuntimeException( - "Memory test failed: Unable to collect memory samples for data size " + - dataSize + " bytes" - ); - } + LatencyResult latencyResult = runItemEncryptorCycle(testData); - BenchmarkResult result = new BenchmarkResult("memory", "java", dataSize, 1); - result.setPeakMemoryMb(memoryResults.peakMemoryMb); - result.setMemoryEfficiencyRatio(memoryResults.peakMemoryMb > 0 ? - dataSize / (memoryResults.peakMemoryMb * 1024 * 1024) : 0.0); - result.setTimestamp(Utils.getCurrentTimestamp()); - result.setJavaVersion(Utils.getJavaVersion()); - result.setCpuCount(cpuCount); - result.setTotalMemoryGb(totalMemoryGb); + long iterationDuration = System.nanoTime() - iterationStart; + double iterationMs = Utils.nanosToMillis(iterationDuration); - return result; + putLatencies.add(latencyResult.putLatencyMs); + getLatencies.add(latencyResult.getLatencyMs); + endToEndLatencies.add(iterationMs); + totalBytes += dataSize; } + double totalDuration = + Utils.nanosToMillis(System.nanoTime() - startTime) / 1000.0; // Convert to seconds + + // Calculate metrics + double[] endToEndArray = endToEndLatencies + .stream() + .mapToDouble(Double::doubleValue) + .toArray(); + Arrays.sort(endToEndArray); + + BenchmarkResult result = new BenchmarkResult( + "throughput", + "java", + dataSize, + 1 + ); + result.setPutLatencyMs(Utils.average(putLatencies)); + result.setGetLatencyMs(Utils.average(getLatencies)); + result.setEndToEndLatencyMs(Utils.average(endToEndLatencies)); + result.setOpsPerSecond(iterations / totalDuration); + result.setBytesPerSecond(totalBytes / totalDuration); + result.setP50Latency(Utils.percentile(endToEndArray, 0.50)); + result.setP95Latency(Utils.percentile(endToEndArray, 0.95)); + result.setP99Latency(Utils.percentile(endToEndArray, 0.99)); + result.setTimestamp(Utils.getCurrentTimestamp()); + result.setJavaVersion(Utils.getJavaVersion()); + result.setCpuCount(cpuCount); + result.setTotalMemoryGb(totalMemoryGb); + + System.out.printf( + "Throughput test completed - Ops/sec: %.2f, MB/sec: %.2f%n", + result.getOpsPerSecond(), + result.getBytesPerSecond() / (1024 * 1024) + ); + + return result; + } + + /** + * Runs memory benchmark tests. + */ + private void runMemoryTests(List dataSizes) throws Exception { + System.out.println("Running memory tests..."); + for (int dataSize : dataSizes) { + BenchmarkResult result = runMemoryTest(dataSize); + if (result != null) { + results.add(result); + System.out.printf( + "Memory test completed: %.2f MB peak%n", + result.getPeakMemoryMb() + ); + } + } + } - /** - * Samples memory usage during multiple test iterations. - */ - private MemoryResults sampleMemoryDuringOperations(byte[] data) { - double peakMemoryDelta = 0.0; - double peakAllocations = 0.0; - List avgMemoryValues = new ArrayList<>(); - - for (int i = 0; i < MEMORY_TEST_ITERATIONS; i++) { - IterationResult iterationResult = runSingleMemoryIteration(data, i + 1); - - if (iterationResult.peakMemory > peakMemoryDelta) { - peakMemoryDelta = iterationResult.peakMemory; - } - if (iterationResult.totalAllocs > peakAllocations) { - peakAllocations = iterationResult.totalAllocs; - } - avgMemoryValues.add(iterationResult.avgMemory); - } + /** + * Gets the total allocated bytes for the current thread. + */ + private static long getTotalAllocatedBytes() { + final var threadBean = ManagementFactory.getThreadMXBean(); + final var sunThreadBean = (com.sun.management.ThreadMXBean) threadBean; - double overallAvgMemory = avgMemoryValues.isEmpty() ? 0.0 : - avgMemoryValues.stream().mapToDouble(Double::doubleValue).average().orElse(0.0); + if (!sunThreadBean.isThreadAllocatedMemoryEnabled()) { + sunThreadBean.setThreadAllocatedMemoryEnabled(true); + } - System.out.println("\nMemory Summary:"); - System.out.printf("- Absolute Peak Heap: %.2f MB (across all runs)%n", peakMemoryDelta); - System.out.printf("- Average Heap: %.2f MB (across all runs)%n", overallAvgMemory); - System.out.printf("- Total Allocations: %.2f MB (max across all runs)%n", peakAllocations); - System.out.flush(); + return sunThreadBean.getCurrentThreadAllocatedBytes(); + } + + /** + * Runs a single memory test with enhanced continuous monitoring. + */ + private BenchmarkResult runMemoryTest(int dataSize) throws Exception { + System.out.printf( + "Running memory test - Size: %d bytes (%d iterations, continuous sampling)%n", + dataSize, + MEMORY_TEST_ITERATIONS + ); + System.out.flush(); + + byte[] data = Utils.generateTestData(dataSize); + MemoryResults memoryResults = sampleMemoryDuringOperations(data); + + if (memoryResults == null) { + throw new RuntimeException( + "Memory test failed: Unable to collect memory samples for data size " + + dataSize + + " bytes" + ); + } - return new MemoryResults(peakMemoryDelta, overallAvgMemory); + BenchmarkResult result = new BenchmarkResult("memory", "java", dataSize, 1); + result.setPeakMemoryMb(memoryResults.peakMemoryMb); + result.setMemoryEfficiencyRatio( + memoryResults.peakMemoryMb > 0 + ? dataSize / (memoryResults.peakMemoryMb * 1024 * 1024) + : 0.0 + ); + result.setTimestamp(Utils.getCurrentTimestamp()); + result.setJavaVersion(Utils.getJavaVersion()); + result.setCpuCount(cpuCount); + result.setTotalMemoryGb(totalMemoryGb); + + return result; + } + + /** + * Samples memory usage during multiple test iterations. + */ + private MemoryResults sampleMemoryDuringOperations(byte[] data) { + double peakMemoryDelta = 0.0; + double peakAllocations = 0.0; + List avgMemoryValues = new ArrayList<>(); + + for (int i = 0; i < MEMORY_TEST_ITERATIONS; i++) { + IterationResult iterationResult = runSingleMemoryIteration(data, i + 1); + + if (iterationResult.peakMemory > peakMemoryDelta) { + peakMemoryDelta = iterationResult.peakMemory; + } + if (iterationResult.totalAllocs > peakAllocations) { + peakAllocations = iterationResult.totalAllocs; + } + avgMemoryValues.add(iterationResult.avgMemory); } - /** - * Runs a single memory iteration with enhanced sampling. - */ - private IterationResult runSingleMemoryIteration(byte[] data, int iteration) { - // Force GC and settle (matching ESDK approach) - System.gc(); - System.gc(); - try { - Thread.sleep(GC_SETTLE_TIME_MS); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException("Memory test interrupted during GC settle phase", e); - } + double overallAvgMemory = avgMemoryValues.isEmpty() + ? 0.0 + : avgMemoryValues + .stream() + .mapToDouble(Double::doubleValue) + .average() + .orElse(0.0); + + System.out.println("\nMemory Summary:"); + System.out.printf( + "- Absolute Peak Heap: %.2f MB (across all runs)%n", + peakMemoryDelta + ); + System.out.printf( + "- Average Heap: %.2f MB (across all runs)%n", + overallAvgMemory + ); + System.out.printf( + "- Total Allocations: %.2f MB (max across all runs)%n", + peakAllocations + ); + System.out.flush(); + + return new MemoryResults(peakMemoryDelta, overallAvgMemory); + } + + /** + * Runs a single memory iteration with enhanced sampling. + */ + private IterationResult runSingleMemoryIteration(byte[] data, int iteration) { + // Force GC and settle (matching ESDK approach) + System.gc(); + System.gc(); + try { + Thread.sleep(GC_SETTLE_TIME_MS); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException( + "Memory test interrupted during GC settle phase", + e + ); + } - long baselineMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); - long baselineAllocations = getTotalAllocatedBytes(); - List memorySamples = new ArrayList<>(); - - long operationStart = System.nanoTime(); - - // Start background sampling - Thread samplingTask = new Thread(() -> { - try { - while (System.nanoTime() - operationStart < 100_000_000) { // 100ms max - long currentMemory = Runtime.getRuntime().totalMemory() - - Runtime.getRuntime().freeMemory(); - long currentAllocations = getTotalAllocatedBytes(); - double heapDelta = (currentMemory - baselineMemory) / (1024.0 * 1024.0); - double cumulativeAllocs = (currentAllocations - baselineAllocations) / (1024.0 * 1024.0); - - if (heapDelta > 0 || cumulativeAllocs > 0) { - synchronized (memorySamples) { - memorySamples.add(new EnhancedMemorySample( - Math.max(0, heapDelta), - Math.max(0, cumulativeAllocs) - )); - } - } - Thread.sleep(SAMPLING_INTERVAL_MS); - } - } catch (InterruptedException e) { - // Expected when operation completes + long baselineMemory = + Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + long baselineAllocations = getTotalAllocatedBytes(); + List memorySamples = new ArrayList<>(); + + long operationStart = System.nanoTime(); + + // Start background sampling + Thread samplingTask = new Thread(() -> { + try { + while (System.nanoTime() - operationStart < 100_000_000) { // 100ms max + long currentMemory = + Runtime.getRuntime().totalMemory() - + Runtime.getRuntime().freeMemory(); + long currentAllocations = getTotalAllocatedBytes(); + double heapDelta = + (currentMemory - baselineMemory) / (1024.0 * 1024.0); + double cumulativeAllocs = + (currentAllocations - baselineAllocations) / (1024.0 * 1024.0); + + if (heapDelta > 0 || cumulativeAllocs > 0) { + synchronized (memorySamples) { + memorySamples.add( + new EnhancedMemorySample( + Math.max(0, heapDelta), + Math.max(0, cumulativeAllocs) + ) + ); } - }); - - samplingTask.start(); - - // Run the actual operation - try { - runItemEncryptorCycle(data); - } catch (Exception e) { - System.out.printf("Memory test iteration %d failed: %s%n", iteration, e.getMessage()); - return new IterationResult(0.0, 0.0, 0.0); + } + Thread.sleep(SAMPLING_INTERVAL_MS); } - - double operationDurationMs = (System.nanoTime() - operationStart) / 1_000_000.0; - - // Wait for sampling to complete - try { - Thread.sleep(FINAL_SAMPLE_WAIT_MS); - samplingTask.join(100); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - - return calculateIterationMetrics( - baselineMemory, - baselineAllocations, - memorySamples, - iteration, - operationDurationMs - ); + } catch (InterruptedException e) { + // Expected when operation completes + } + }); + + samplingTask.start(); + + // Run the actual operation + try { + runItemEncryptorCycle(data); + } catch (Exception e) { + System.out.printf( + "Memory test iteration %d failed: %s%n", + iteration, + e.getMessage() + ); + return new IterationResult(0.0, 0.0, 0.0); } - /** - * Calculates comprehensive metrics for a single iteration. - */ - private IterationResult calculateIterationMetrics( - long baselineMemory, - long baselineAllocations, - List memorySamples, - int iteration, - double operationDurationMs - ) { - long finalMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); - long finalAllocations = getTotalAllocatedBytes(); - double finalHeapDelta = (finalMemory - baselineMemory) / (1024.0 * 1024.0); - double finalCumulativeAllocs = (finalAllocations - baselineAllocations) / (1024.0 * 1024.0); - - double iterPeakMemory; - double iterTotalAllocs; - double iterAvgMemory; - - synchronized (memorySamples) { - if (memorySamples.isEmpty()) { - iterPeakMemory = Math.max(0, finalHeapDelta); - iterTotalAllocs = Math.max(0, finalCumulativeAllocs); - iterAvgMemory = Math.max(0, finalHeapDelta); - } else { - iterPeakMemory = memorySamples.stream().mapToDouble(s -> s.heapMB).max().orElse(0.0); - iterTotalAllocs = Math.max(0, finalCumulativeAllocs); - iterAvgMemory = memorySamples.stream().mapToDouble(s -> s.heapMB).average().orElse(0.0); - } - } + double operationDurationMs = + (System.nanoTime() - operationStart) / 1_000_000.0; - System.out.printf("=== Iteration %d === Peak Heap: %.2f MB, Total Allocs: %.2f MB, " + - "Avg Heap: %.2f MB (%.0fms, %d samples)%n", - iteration, iterPeakMemory, iterTotalAllocs, iterAvgMemory, - operationDurationMs, memorySamples.size()); - System.out.flush(); + // Wait for sampling to complete + try { + Thread.sleep(FINAL_SAMPLE_WAIT_MS); + samplingTask.join(100); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } - return new IterationResult(iterPeakMemory, iterTotalAllocs, iterAvgMemory); + return calculateIterationMetrics( + baselineMemory, + baselineAllocations, + memorySamples, + iteration, + operationDurationMs + ); + } + + /** + * Calculates comprehensive metrics for a single iteration. + */ + private IterationResult calculateIterationMetrics( + long baselineMemory, + long baselineAllocations, + List memorySamples, + int iteration, + double operationDurationMs + ) { + long finalMemory = + Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + long finalAllocations = getTotalAllocatedBytes(); + double finalHeapDelta = (finalMemory - baselineMemory) / (1024.0 * 1024.0); + double finalCumulativeAllocs = + (finalAllocations - baselineAllocations) / (1024.0 * 1024.0); + + double iterPeakMemory; + double iterTotalAllocs; + double iterAvgMemory; + + synchronized (memorySamples) { + if (memorySamples.isEmpty()) { + iterPeakMemory = Math.max(0, finalHeapDelta); + iterTotalAllocs = Math.max(0, finalCumulativeAllocs); + iterAvgMemory = Math.max(0, finalHeapDelta); + } else { + iterPeakMemory = + memorySamples.stream().mapToDouble(s -> s.heapMB).max().orElse(0.0); + iterTotalAllocs = Math.max(0, finalCumulativeAllocs); + iterAvgMemory = + memorySamples + .stream() + .mapToDouble(s -> s.heapMB) + .average() + .orElse(0.0); + } } - /** - * Runs concurrency benchmark tests. - */ - private void runConcurrencyTests(List dataSizes, List concurrencyLevels) throws Exception { - System.out.println("Running concurrency tests..."); - for (int dataSize : dataSizes) { - for (int concurrency : concurrencyLevels) { - if (concurrency > 1) { // Skip single-threaded - BenchmarkResult result = runConcurrentTest(dataSize, concurrency, 5); - if (result != null) { - results.add(result); - System.out.printf("Concurrent test completed: %.2f ops/sec @ %d threads%n", - result.getOpsPerSecond(), concurrency); - } - } - } + System.out.printf( + "=== Iteration %d === Peak Heap: %.2f MB, Total Allocs: %.2f MB, " + + "Avg Heap: %.2f MB (%.0fms, %d samples)%n", + iteration, + iterPeakMemory, + iterTotalAllocs, + iterAvgMemory, + operationDurationMs, + memorySamples.size() + ); + System.out.flush(); + + return new IterationResult(iterPeakMemory, iterTotalAllocs, iterAvgMemory); + } + + /** + * Runs concurrency benchmark tests. + */ + private void runConcurrencyTests( + List dataSizes, + List concurrencyLevels + ) throws Exception { + System.out.println("Running concurrency tests..."); + for (int dataSize : dataSizes) { + for (int concurrency : concurrencyLevels) { + if (concurrency > 1) { // Skip single-threaded + BenchmarkResult result = runConcurrentTest(dataSize, concurrency, 5); + if (result != null) { + results.add(result); + System.out.printf( + "Concurrent test completed: %.2f ops/sec @ %d threads%n", + result.getOpsPerSecond(), + concurrency + ); + } } + } } - - /** - * Runs a single concurrent test. - */ - private BenchmarkResult runConcurrentTest(int dataSize, int concurrency, int iterationsPerWorker) throws Exception { - System.out.printf("Running concurrent test - Size: %d bytes, Concurrency: %d%n", dataSize, concurrency); - - byte[] data = Utils.generateTestData(dataSize); - List allTimes = Collections.synchronizedList(new ArrayList<>()); - ExecutorService executor = Executors.newFixedThreadPool(concurrency); - - long startTime = System.nanoTime(); - - try { - // Submit workers - List> futures = new ArrayList<>(); - for (int i = 0; i < concurrency; i++) { - final int workerId = i; - CompletableFuture future = CompletableFuture.runAsync(() -> { - for (int j = 0; j < iterationsPerWorker; j++) { - try { - long iterStart = System.nanoTime(); - runItemEncryptorCycle(data); - double iterMs = Utils.nanosToMillis(System.nanoTime() - iterStart); - allTimes.add(iterMs); - } catch (Exception e) { - throw new RuntimeException(String.format("Worker %d iteration %d failed: %s", - workerId, j, e.getMessage()), e); - } - } - }, executor); - futures.add(future); + } + + /** + * Runs a single concurrent test. + */ + private BenchmarkResult runConcurrentTest( + int dataSize, + int concurrency, + int iterationsPerWorker + ) throws Exception { + System.out.printf( + "Running concurrent test - Size: %d bytes, Concurrency: %d%n", + dataSize, + concurrency + ); + + byte[] data = Utils.generateTestData(dataSize); + List allTimes = Collections.synchronizedList(new ArrayList<>()); + ExecutorService executor = Executors.newFixedThreadPool(concurrency); + + long startTime = System.nanoTime(); + + try { + // Submit workers + List> futures = new ArrayList<>(); + for (int i = 0; i < concurrency; i++) { + final int workerId = i; + CompletableFuture future = CompletableFuture.runAsync( + () -> { + for (int j = 0; j < iterationsPerWorker; j++) { + try { + long iterStart = System.nanoTime(); + runItemEncryptorCycle(data); + double iterMs = Utils.nanosToMillis( + System.nanoTime() - iterStart + ); + allTimes.add(iterMs); + } catch (Exception e) { + throw new RuntimeException( + String.format( + "Worker %d iteration %d failed: %s", + workerId, + j, + e.getMessage() + ), + e + ); + } } + }, + executor + ); + futures.add(future); + } - // Wait for all workers to complete - CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(); - - } finally { - executor.shutdown(); - } - - double totalDurationSec = Utils.nanosToMillis(System.nanoTime() - startTime) / 1000.0; - - // Calculate metrics - int totalOps = concurrency * iterationsPerWorker; - long totalBytes = (long) totalOps * dataSize; - - double[] timesArray = allTimes.stream().mapToDouble(Double::doubleValue).toArray(); - Arrays.sort(timesArray); - - BenchmarkResult result = new BenchmarkResult("concurrent", "java", dataSize, concurrency); - result.setEndToEndLatencyMs(Utils.average(timesArray)); - result.setOpsPerSecond(totalOps / totalDurationSec); - result.setBytesPerSecond(totalBytes / totalDurationSec); - result.setP50Latency(Utils.percentile(timesArray, 0.50)); - result.setP95Latency(Utils.percentile(timesArray, 0.95)); - result.setP99Latency(Utils.percentile(timesArray, 0.99)); - result.setTimestamp(Utils.getCurrentTimestamp()); - result.setJavaVersion(Utils.getJavaVersion()); - result.setCpuCount(cpuCount); - result.setTotalMemoryGb(totalMemoryGb); - - System.out.printf("Concurrent test completed - Ops/sec: %.2f, Avg latency: %.2f ms%n", - result.getOpsPerSecond(), result.getEndToEndLatencyMs()); - - return result; + // Wait for all workers to complete + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(); + } finally { + executor.shutdown(); } - /** - * Performs a single encrypt-decrypt cycle and measures performance. - */ - private LatencyResult runItemEncryptorCycle(byte[] data) throws Exception { - // Create DynamoDB item - Map item = new HashMap<>(); - item.put("partition_key", AttributeValue.builder().s("benchmark-test").build()); - item.put("sort_key", AttributeValue.builder().n("0").build()); - - Map nestedMap = new HashMap<>(); - nestedMap.put("data", AttributeValue.builder().b(SdkBytes.fromByteArray(data)).build()); - item.put("attribute1", AttributeValue.builder().m(nestedMap).build()); - - item.put("attribute2", AttributeValue.builder().s("sign me!").build()); - item.put(":attribute3", AttributeValue.builder().s("ignore me!").build()); - - // Encrypt item - long encryptStart = System.nanoTime(); - EncryptItemInput encryptInput = EncryptItemInput.builder().plaintextItem(item).build(); - EncryptItemOutput encryptOutput = itemEncryptor.EncryptItem(encryptInput); - double putLatencyMs = Utils.nanosToMillis(System.nanoTime() - encryptStart); - - Map encryptedItem = encryptOutput.encryptedItem(); - - // Decrypt item - long decryptStart = System.nanoTime(); - DecryptItemInput decryptInput = DecryptItemInput.builder().encryptedItem(encryptedItem).build(); - DecryptItemOutput decryptOutput = itemEncryptor.DecryptItem(decryptInput); - double getLatencyMs = Utils.nanosToMillis(System.nanoTime() - decryptStart); - - Map decryptedItem = decryptOutput.plaintextItem(); - - // Verify items match (basic check) - if (!item.equals(decryptedItem)) { - throw new RuntimeException("Decrypted item does not match original item"); - } - - return new LatencyResult(putLatencyMs, getLatencyMs); + double totalDurationSec = + Utils.nanosToMillis(System.nanoTime() - startTime) / 1000.0; + + // Calculate metrics + int totalOps = concurrency * iterationsPerWorker; + long totalBytes = (long) totalOps * dataSize; + + double[] timesArray = allTimes + .stream() + .mapToDouble(Double::doubleValue) + .toArray(); + Arrays.sort(timesArray); + + BenchmarkResult result = new BenchmarkResult( + "concurrent", + "java", + dataSize, + concurrency + ); + result.setEndToEndLatencyMs(Utils.average(timesArray)); + result.setOpsPerSecond(totalOps / totalDurationSec); + result.setBytesPerSecond(totalBytes / totalDurationSec); + result.setP50Latency(Utils.percentile(timesArray, 0.50)); + result.setP95Latency(Utils.percentile(timesArray, 0.95)); + result.setP99Latency(Utils.percentile(timesArray, 0.99)); + result.setTimestamp(Utils.getCurrentTimestamp()); + result.setJavaVersion(Utils.getJavaVersion()); + result.setCpuCount(cpuCount); + result.setTotalMemoryGb(totalMemoryGb); + + System.out.printf( + "Concurrent test completed - Ops/sec: %.2f, Avg latency: %.2f ms%n", + result.getOpsPerSecond(), + result.getEndToEndLatencyMs() + ); + + return result; + } + + /** + * Performs a single encrypt-decrypt cycle and measures performance. + */ + private LatencyResult runItemEncryptorCycle(byte[] data) throws Exception { + // Create DynamoDB item + Map item = new HashMap<>(); + item.put( + "partition_key", + AttributeValue.builder().s("benchmark-test").build() + ); + item.put("sort_key", AttributeValue.builder().n("0").build()); + + Map nestedMap = new HashMap<>(); + nestedMap.put( + "data", + AttributeValue.builder().b(SdkBytes.fromByteArray(data)).build() + ); + item.put("attribute1", AttributeValue.builder().m(nestedMap).build()); + + item.put("attribute2", AttributeValue.builder().s("sign me!").build()); + item.put(":attribute3", AttributeValue.builder().s("ignore me!").build()); + + // Encrypt item + long encryptStart = System.nanoTime(); + EncryptItemInput encryptInput = EncryptItemInput + .builder() + .plaintextItem(item) + .build(); + EncryptItemOutput encryptOutput = itemEncryptor.EncryptItem(encryptInput); + double putLatencyMs = Utils.nanosToMillis(System.nanoTime() - encryptStart); + + Map encryptedItem = encryptOutput.encryptedItem(); + + // Decrypt item + long decryptStart = System.nanoTime(); + DecryptItemInput decryptInput = DecryptItemInput + .builder() + .encryptedItem(encryptedItem) + .build(); + DecryptItemOutput decryptOutput = itemEncryptor.DecryptItem(decryptInput); + double getLatencyMs = Utils.nanosToMillis(System.nanoTime() - decryptStart); + + Map decryptedItem = decryptOutput.plaintextItem(); + + // Verify items match (basic check) + if (!item.equals(decryptedItem)) { + throw new RuntimeException("Decrypted item does not match original item"); } - /** - * Saves benchmark results to JSON file. - */ - public void saveResults(String outputPath) throws IOException { - // Ensure output directory exists - Path outputFilePath = Paths.get(outputPath); - Files.createDirectories(outputFilePath.getParent()); - - // Create results structure matching Go implementation - Map resultsData = new HashMap<>(); - - Map metadata = new HashMap<>(); - metadata.put("language", "java"); - metadata.put("timestamp", Utils.getCurrentTimestamp()); - metadata.put("java_version", Utils.getJavaVersion()); - metadata.put("cpu_count", cpuCount); - metadata.put("total_memory_gb", totalMemoryGb); - metadata.put("total_tests", results.size()); - - resultsData.put("metadata", metadata); - resultsData.put("results", results); - - // Write to JSON file with proper formatting - ObjectMapper mapper = new ObjectMapper(); - mapper.writerWithDefaultPrettyPrinter().writeValue(new File(outputPath), resultsData); - - System.out.printf("Results saved to: %s%n", outputPath); + return new LatencyResult(putLatencyMs, getLatencyMs); + } + + /** + * Saves benchmark results to JSON file. + */ + public void saveResults(String outputPath) throws IOException { + // Ensure output directory exists + Path outputFilePath = Paths.get(outputPath); + Files.createDirectories(outputFilePath.getParent()); + + // Create results structure matching Go implementation + Map resultsData = new HashMap<>(); + + Map metadata = new HashMap<>(); + metadata.put("language", "java"); + metadata.put("timestamp", Utils.getCurrentTimestamp()); + metadata.put("java_version", Utils.getJavaVersion()); + metadata.put("cpu_count", cpuCount); + metadata.put("total_memory_gb", totalMemoryGb); + metadata.put("total_tests", results.size()); + + resultsData.put("metadata", metadata); + resultsData.put("results", results); + + // Write to JSON file with proper formatting + ObjectMapper mapper = new ObjectMapper(); + mapper + .writerWithDefaultPrettyPrinter() + .writeValue(new File(outputPath), resultsData); + + System.out.printf("Results saved to: %s%n", outputPath); + } + + // Getters + public TestConfig getConfig() { + return config; + } + + public List getResults() { + return results; + } + + /** + * Helper class to hold latency results. + */ + private static class LatencyResult { + + final double putLatencyMs; + final double getLatencyMs; + + LatencyResult(double putLatencyMs, double getLatencyMs) { + this.putLatencyMs = putLatencyMs; + this.getLatencyMs = getLatencyMs; } + } - // Getters - public TestConfig getConfig() { return config; } - public List getResults() { return results; } - - /** - * Helper class to hold latency results. - */ - private static class LatencyResult { - final double putLatencyMs; - final double getLatencyMs; + // Helper records for enhanced memory testing + private record IterationResult( + double peakMemory, + double totalAllocs, + double avgMemory + ) {} - LatencyResult(double putLatencyMs, double getLatencyMs) { - this.putLatencyMs = putLatencyMs; - this.getLatencyMs = getLatencyMs; - } - } + private record MemoryResults(double peakMemoryMb, double avgMemoryMb) {} - // Helper records for enhanced memory testing - private record IterationResult(double peakMemory, double totalAllocs, double avgMemory) {} - - private record MemoryResults(double peakMemoryMb, double avgMemoryMb) {} - - private record EnhancedMemorySample(double heapMB, double allocsMB) {} + private record EnhancedMemorySample(double heapMB, double allocsMB) {} } diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java index aed7c11899..3fe7b6c42e 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/KeyringSetup.java @@ -3,64 +3,67 @@ package com.amazon.dbesdk.benchmark; +import java.nio.ByteBuffer; +import java.security.SecureRandom; +import java.util.Map; import software.amazon.cryptography.materialproviders.IKeyring; import software.amazon.cryptography.materialproviders.MaterialProviders; import software.amazon.cryptography.materialproviders.model.AesWrappingAlg; import software.amazon.cryptography.materialproviders.model.CreateRawAesKeyringInput; import software.amazon.cryptography.materialproviders.model.MaterialProvidersConfig; -import java.nio.ByteBuffer; -import java.security.SecureRandom; -import java.util.Map; - /** * Helper class for setting up keyrings for DB-ESDK benchmarks. */ public class KeyringSetup { - - private static final String RAW_AES_KEYRING = "raw-aes"; - /** - * Creates a keyring based on the specified type. - * - * @param keyringType The type of keyring to create - * @return The configured keyring - * @throws Exception if keyring creation fails - */ - public static IKeyring createKeyring(String keyringType) throws Exception { - if (RAW_AES_KEYRING.equals(keyringType)) { - return createRawAesKeyring(); - } else { - throw new IllegalArgumentException("Unsupported keyring type: " + keyringType); - } + private static final String RAW_AES_KEYRING = "raw-aes"; + + /** + * Creates a keyring based on the specified type. + * + * @param keyringType The type of keyring to create + * @return The configured keyring + * @throws Exception if keyring creation fails + */ + public static IKeyring createKeyring(String keyringType) throws Exception { + if (RAW_AES_KEYRING.equals(keyringType)) { + return createRawAesKeyring(); + } else { + throw new IllegalArgumentException( + "Unsupported keyring type: " + keyringType + ); } + } - /** - * Creates a Raw AES keyring with a randomly generated 256-bit key. - * This matches the Go implementation's keyring setup. - * - * @return Raw AES keyring - * @throws Exception if keyring creation fails - */ - private static IKeyring createRawAesKeyring() throws Exception { - // Initialize Material Providers client - MaterialProviders matProv = MaterialProviders.builder() - .MaterialProvidersConfig(MaterialProvidersConfig.builder().build()) - .build(); + /** + * Creates a Raw AES keyring with a randomly generated 256-bit key. + * This matches the Go implementation's keyring setup. + * + * @return Raw AES keyring + * @throws Exception if keyring creation fails + */ + private static IKeyring createRawAesKeyring() throws Exception { + // Initialize Material Providers client + MaterialProviders matProv = MaterialProviders + .builder() + .MaterialProvidersConfig(MaterialProvidersConfig.builder().build()) + .build(); - // Generate a 256-bit (32-byte) random key - byte[] key = new byte[32]; - new SecureRandom().nextBytes(key); + // Generate a 256-bit (32-byte) random key + byte[] key = new byte[32]; + new SecureRandom().nextBytes(key); - // Create Raw AES keyring input - CreateRawAesKeyringInput keyringInput = CreateRawAesKeyringInput.builder() - .keyName("test-aes-256-key") - .keyNamespace("DB-ESDK-performance-test") - .wrappingKey(ByteBuffer.wrap(key)) - .wrappingAlg(AesWrappingAlg.ALG_AES256_GCM_IV12_TAG16) - .build(); + // Create Raw AES keyring input + CreateRawAesKeyringInput keyringInput = CreateRawAesKeyringInput + .builder() + .keyName("test-aes-256-key") + .keyNamespace("DB-ESDK-performance-test") + .wrappingKey(ByteBuffer.wrap(key)) + .wrappingAlg(AesWrappingAlg.ALG_AES256_GCM_IV12_TAG16) + .build(); - // Create and return the keyring - return matProv.CreateRawAesKeyring(keyringInput); - } + // Create and return the keyring + return matProv.CreateRawAesKeyring(keyringInput); + } } diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java index 2bda04fe78..36b315c1b4 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java @@ -3,221 +3,285 @@ package com.amazon.dbesdk.benchmark; -import org.apache.commons.cli.*; - import java.io.IOException; import java.util.List; +import org.apache.commons.cli.*; /** * Main entry point for the DB-ESDK Java performance benchmark. */ public class Program { - public static void main(String[] args) { - CommandLineOptions options = parseArgs(args); - if (options == null) { - return; - } - - try { - // Initialize benchmark - DBESDKBenchmark benchmark = new DBESDKBenchmark(options.getConfigPath()); - - // Adjust config for quick test if requested - if (options.isQuickTest()) { - benchmark.getConfig().adjustForQuickTest(); - } - - System.out.println("\n=== Starting DB-ESDK Java Benchmark ==="); - System.out.printf("Configuration: %s%n", options.getConfigPath()); - System.out.printf("Output: %s%n", options.getOutputPath()); - System.out.printf("Quick mode: %s%n", options.isQuickTest()); - System.out.printf("System: %d CPU cores, %.1f GB memory%n", - Utils.getCpuCount(), Utils.getTotalMemoryGb()); - - // Run benchmarks - List results = benchmark.runAllBenchmarks(); - - // Save results - benchmark.saveResults(options.getOutputPath()); - - // Print summary - printSummary(results, options.getOutputPath()); - - } catch (Exception e) { - System.err.println("Benchmark failed: " + e.getMessage()); - e.printStackTrace(); - System.exit(1); - } + public static void main(String[] args) { + CommandLineOptions options = parseArgs(args); + if (options == null) { + return; } - /** - * Parses command line arguments. - */ - private static CommandLineOptions parseArgs(String[] args) { - Options options = new Options(); - - options.addOption(Option.builder("c") - .longOpt("config") - .hasArg() - .argName("file") - .desc("Path to test configuration file (default: ../config/test-scenarios.yaml)") - .build()); - - options.addOption(Option.builder("o") - .longOpt("output") - .hasArg() - .argName("file") - .desc("Path to output results file (default: ../results/raw-data/java_results.json)") - .build()); - - options.addOption(Option.builder("q") - .longOpt("quick") - .desc("Run quick test with reduced iterations") - .build()); - - options.addOption(Option.builder("h") - .longOpt("help") - .desc("Show this help message") - .build()); - - CommandLineParser parser = new DefaultParser(); - try { - CommandLine cmd = parser.parse(options, args); - - if (cmd.hasOption("h")) { - printUsage(options); - return null; - } - - String configPath = cmd.getOptionValue("c", "../config/test-scenarios.yaml"); - String outputPath = cmd.getOptionValue("o", "../results/raw-data/java_results.json"); - boolean quickTest = cmd.hasOption("q"); - - return new CommandLineOptions(configPath, outputPath, quickTest); - - } catch (ParseException e) { - System.err.println("Error parsing command line: " + e.getMessage()); - printUsage(options); - return null; - } + try { + // Initialize benchmark + DBESDKBenchmark benchmark = new DBESDKBenchmark(options.getConfigPath()); + + // Adjust config for quick test if requested + if (options.isQuickTest()) { + benchmark.getConfig().adjustForQuickTest(); + } + + System.out.println("\n=== Starting DB-ESDK Java Benchmark ==="); + System.out.printf("Configuration: %s%n", options.getConfigPath()); + System.out.printf("Output: %s%n", options.getOutputPath()); + System.out.printf("Quick mode: %s%n", options.isQuickTest()); + System.out.printf( + "System: %d CPU cores, %.1f GB memory%n", + Utils.getCpuCount(), + Utils.getTotalMemoryGb() + ); + + // Run benchmarks + List results = benchmark.runAllBenchmarks(); + + // Save results + benchmark.saveResults(options.getOutputPath()); + + // Print summary + printSummary(results, options.getOutputPath()); + } catch (Exception e) { + System.err.println("Benchmark failed: " + e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + } + + /** + * Parses command line arguments. + */ + private static CommandLineOptions parseArgs(String[] args) { + Options options = new Options(); + + options.addOption( + Option + .builder("c") + .longOpt("config") + .hasArg() + .argName("file") + .desc( + "Path to test configuration file (default: ../config/test-scenarios.yaml)" + ) + .build() + ); + + options.addOption( + Option + .builder("o") + .longOpt("output") + .hasArg() + .argName("file") + .desc( + "Path to output results file (default: ../results/raw-data/java_results.json)" + ) + .build() + ); + + options.addOption( + Option + .builder("q") + .longOpt("quick") + .desc("Run quick test with reduced iterations") + .build() + ); + + options.addOption( + Option.builder("h").longOpt("help").desc("Show this help message").build() + ); + + CommandLineParser parser = new DefaultParser(); + try { + CommandLine cmd = parser.parse(options, args); + + if (cmd.hasOption("h")) { + printUsage(options); + return null; + } + + String configPath = cmd.getOptionValue( + "c", + "../config/test-scenarios.yaml" + ); + String outputPath = cmd.getOptionValue( + "o", + "../results/raw-data/java_results.json" + ); + boolean quickTest = cmd.hasOption("q"); + + return new CommandLineOptions(configPath, outputPath, quickTest); + } catch (ParseException e) { + System.err.println("Error parsing command line: " + e.getMessage()); + printUsage(options); + return null; + } + } + + /** + * Prints usage information. + */ + private static void printUsage(Options options) { + HelpFormatter formatter = new HelpFormatter(); + System.out.println("DB-ESDK Java Performance Benchmark"); + System.out.println(); + formatter.printHelp("java -jar db-esdk-benchmark.jar [options]", options); + System.out.println(); + System.out.println("Examples:"); + System.out.println(" # Run quick benchmark"); + System.out.println(" java -jar db-esdk-benchmark.jar --quick"); + System.out.println(); + System.out.println(" # Run full benchmark with custom config"); + System.out.println( + " java -jar db-esdk-benchmark.jar -c /path/to/config.yaml -o /path/to/results.json" + ); + System.out.println(); + System.out.println(" # Using Gradle"); + System.out.println(" ./gradlew run --args=\"--quick\""); + } + + /** + * Prints benchmark summary. + */ + private static void printSummary( + List results, + String outputPath + ) { + System.out.println("\n=== DB-ESDK Java Benchmark Summary ==="); + System.out.printf("Total tests completed: %d%n", results.size()); + System.out.printf("Results saved to: %s%n", outputPath); + + if (!results.isEmpty()) { + // Find maximum throughput + double maxThroughput = results + .stream() + .filter(r -> "throughput".equals(r.getTestName())) + .mapToDouble(BenchmarkResult::getOpsPerSecond) + .max() + .orElse(0.0); + + if (maxThroughput > 0) { + System.out.printf("Maximum throughput: %.2f ops/sec%n", maxThroughput); + } + + // Print some sample results by test type + System.out.println(); + printTestTypeSummary(results, "throughput"); + printTestTypeSummary(results, "memory"); + printTestTypeSummary(results, "concurrent"); } - /** - * Prints usage information. - */ - private static void printUsage(Options options) { - HelpFormatter formatter = new HelpFormatter(); - System.out.println("DB-ESDK Java Performance Benchmark"); - System.out.println(); - formatter.printHelp("java -jar db-esdk-benchmark.jar [options]", options); - System.out.println(); - System.out.println("Examples:"); - System.out.println(" # Run quick benchmark"); - System.out.println(" java -jar db-esdk-benchmark.jar --quick"); - System.out.println(); - System.out.println(" # Run full benchmark with custom config"); - System.out.println(" java -jar db-esdk-benchmark.jar -c /path/to/config.yaml -o /path/to/results.json"); - System.out.println(); - System.out.println(" # Using Gradle"); - System.out.println(" ./gradlew run --args=\"--quick\""); + System.out.println("\n=== Benchmark Complete ==="); + } + + /** + * Prints summary for a specific test type. + */ + private static void printTestTypeSummary( + List results, + String testType + ) { + List testResults = results + .stream() + .filter(r -> testType.equals(r.getTestName())) + .toList(); + + if (testResults.isEmpty()) { + return; } - /** - * Prints benchmark summary. - */ - private static void printSummary(List results, String outputPath) { - System.out.println("\n=== DB-ESDK Java Benchmark Summary ==="); - System.out.printf("Total tests completed: %d%n", results.size()); - System.out.printf("Results saved to: %s%n", outputPath); - - if (!results.isEmpty()) { - // Find maximum throughput - double maxThroughput = results.stream() - .filter(r -> "throughput".equals(r.getTestName())) - .mapToDouble(BenchmarkResult::getOpsPerSecond) - .max() - .orElse(0.0); - - if (maxThroughput > 0) { - System.out.printf("Maximum throughput: %.2f ops/sec%n", maxThroughput); - } - - // Print some sample results by test type - System.out.println(); - printTestTypeSummary(results, "throughput"); - printTestTypeSummary(results, "memory"); - printTestTypeSummary(results, "concurrent"); - } - - System.out.println("\n=== Benchmark Complete ==="); + System.out.printf( + "\n%s Tests (%d results):%n", + testType.substring(0, 1).toUpperCase() + testType.substring(1), + testResults.size() + ); + + if ("throughput".equals(testType)) { + testResults + .stream() + .limit(3) // Show first 3 results + .forEach(r -> + System.out.printf( + " %s: %.2f ops/sec, %.2f ms latency%n", + formatDataSize(r.getDataSize()), + r.getOpsPerSecond(), + r.getEndToEndLatencyMs() + ) + ); + } else if ("memory".equals(testType)) { + testResults + .stream() + .limit(3) + .forEach(r -> + System.out.printf( + " %s: %.2f MB peak, %.4f efficiency%n", + formatDataSize(r.getDataSize()), + r.getPeakMemoryMb(), + r.getMemoryEfficiencyRatio() + ) + ); + } else if ("concurrent".equals(testType)) { + testResults + .stream() + .limit(3) + .forEach(r -> + System.out.printf( + " %s (%d threads): %.2f ops/sec%n", + formatDataSize(r.getDataSize()), + r.getConcurrency(), + r.getOpsPerSecond() + ) + ); + } + } + + /** + * Formats data size for display. + */ + private static String formatDataSize(int bytes) { + if (bytes >= 1024 * 1024 * 1024) { + return String.format("%.0f GB", bytes / (1024.0 * 1024.0 * 1024.0)); + } else if (bytes >= 1024 * 1024) { + return String.format("%.0f MB", bytes / (1024.0 * 1024.0)); + } else if (bytes >= 1024) { + return String.format("%.0f KB", bytes / 1024.0); + } else { + return bytes + " B"; + } + } + + /** + * Command line options holder. + */ + public static class CommandLineOptions { + + private final String configPath; + private final String outputPath; + private final boolean quickTest; + + public CommandLineOptions( + String configPath, + String outputPath, + boolean quickTest + ) { + this.configPath = configPath; + this.outputPath = outputPath; + this.quickTest = quickTest; } - /** - * Prints summary for a specific test type. - */ - private static void printTestTypeSummary(List results, String testType) { - List testResults = results.stream() - .filter(r -> testType.equals(r.getTestName())) - .toList(); - - if (testResults.isEmpty()) { - return; - } - - System.out.printf("\n%s Tests (%d results):%n", - testType.substring(0, 1).toUpperCase() + testType.substring(1), - testResults.size()); - - if ("throughput".equals(testType)) { - testResults.stream() - .limit(3) // Show first 3 results - .forEach(r -> System.out.printf(" %s: %.2f ops/sec, %.2f ms latency%n", - formatDataSize(r.getDataSize()), r.getOpsPerSecond(), r.getEndToEndLatencyMs())); - } else if ("memory".equals(testType)) { - testResults.stream() - .limit(3) - .forEach(r -> System.out.printf(" %s: %.2f MB peak, %.4f efficiency%n", - formatDataSize(r.getDataSize()), r.getPeakMemoryMb(), r.getMemoryEfficiencyRatio())); - } else if ("concurrent".equals(testType)) { - testResults.stream() - .limit(3) - .forEach(r -> System.out.printf(" %s (%d threads): %.2f ops/sec%n", - formatDataSize(r.getDataSize()), r.getConcurrency(), r.getOpsPerSecond())); - } + public String getConfigPath() { + return configPath; } - /** - * Formats data size for display. - */ - private static String formatDataSize(int bytes) { - if (bytes >= 1024 * 1024 * 1024) { - return String.format("%.0f GB", bytes / (1024.0 * 1024.0 * 1024.0)); - } else if (bytes >= 1024 * 1024) { - return String.format("%.0f MB", bytes / (1024.0 * 1024.0)); - } else if (bytes >= 1024) { - return String.format("%.0f KB", bytes / 1024.0); - } else { - return bytes + " B"; - } + public String getOutputPath() { + return outputPath; } - /** - * Command line options holder. - */ - public static class CommandLineOptions { - private final String configPath; - private final String outputPath; - private final boolean quickTest; - - public CommandLineOptions(String configPath, String outputPath, boolean quickTest) { - this.configPath = configPath; - this.outputPath = outputPath; - this.quickTest = quickTest; - } - - public String getConfigPath() { return configPath; } - public String getOutputPath() { return outputPath; } - public boolean isQuickTest() { return quickTest; } + public boolean isQuickTest() { + return quickTest; } + } } diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java index edfbb4c465..1e8528db94 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java @@ -3,193 +3,295 @@ package com.amazon.dbesdk.benchmark; -import org.yaml.snakeyaml.Yaml; - import java.io.FileInputStream; import java.io.IOException; import java.util.List; import java.util.Map; +import org.yaml.snakeyaml.Yaml; /** * Configuration class for DB-ESDK benchmark tests, loaded from YAML. */ public class TestConfig { + + private DataSizes dataSizes; + private Iterations iterations; + private List concurrencyLevels; + private QuickConfig quickConfig; + private String tableName; + private String keyring; + + // Nested classes for structured configuration + public static class DataSizes { + + private List small; + private List medium; + private List large; + + public List getSmall() { + return small; + } + + public void setSmall(List small) { + this.small = small; + } + + public List getMedium() { + return medium; + } + + public void setMedium(List medium) { + this.medium = medium; + } + + public List getLarge() { + return large; + } + + public void setLarge(List large) { + this.large = large; + } + } + + public static class Iterations { + + private int warmup; + private int measurement; + + public int getWarmup() { + return warmup; + } + + public void setWarmup(int warmup) { + this.warmup = warmup; + } + + public int getMeasurement() { + return measurement; + } + + public void setMeasurement(int measurement) { + this.measurement = measurement; + } + } + + public static class QuickConfig { + private DataSizes dataSizes; private Iterations iterations; private List concurrencyLevels; - private QuickConfig quickConfig; - private String tableName; - private String keyring; - - // Nested classes for structured configuration - public static class DataSizes { - private List small; - private List medium; - private List large; - - public List getSmall() { return small; } - public void setSmall(List small) { this.small = small; } - - public List getMedium() { return medium; } - public void setMedium(List medium) { this.medium = medium; } - - public List getLarge() { return large; } - public void setLarge(List large) { this.large = large; } - } - - public static class Iterations { - private int warmup; - private int measurement; - - public int getWarmup() { return warmup; } - public void setWarmup(int warmup) { this.warmup = warmup; } - - public int getMeasurement() { return measurement; } - public void setMeasurement(int measurement) { this.measurement = measurement; } - } - - public static class QuickConfig { - private DataSizes dataSizes; - private Iterations iterations; - private List concurrencyLevels; - private List testTypes; - - public DataSizes getDataSizes() { return dataSizes; } - public void setDataSizes(DataSizes dataSizes) { this.dataSizes = dataSizes; } - - public Iterations getIterations() { return iterations; } - public void setIterations(Iterations iterations) { this.iterations = iterations; } - - public List getConcurrencyLevels() { return concurrencyLevels; } - public void setConcurrencyLevels(List concurrencyLevels) { this.concurrencyLevels = concurrencyLevels; } - - public List getTestTypes() { return testTypes; } - public void setTestTypes(List testTypes) { this.testTypes = testTypes; } - } - - // Main getters and setters - public DataSizes getDataSizes() { return dataSizes; } - public void setDataSizes(DataSizes dataSizes) { this.dataSizes = dataSizes; } - - public Iterations getIterations() { return iterations; } - public void setIterations(Iterations iterations) { this.iterations = iterations; } - - public List getConcurrencyLevels() { return concurrencyLevels; } - public void setConcurrencyLevels(List concurrencyLevels) { this.concurrencyLevels = concurrencyLevels; } - - public QuickConfig getQuickConfig() { return quickConfig; } - public void setQuickConfig(QuickConfig quickConfig) { this.quickConfig = quickConfig; } - - public String getTableName() { return tableName; } - public void setTableName(String tableName) { this.tableName = tableName; } - - public String getKeyring() { return keyring; } - public void setKeyring(String keyring) { this.keyring = keyring; } - - /** - * Loads test configuration from YAML file. - */ - public static TestConfig loadConfig(String configPath) throws IOException { - Yaml yaml = new Yaml(); - try (FileInputStream fis = new FileInputStream(configPath)) { - Map yamlData = yaml.load(fis); - return parseYamlToConfig(yamlData); - } - } - - /** - * Parses the YAML data structure into TestConfig object. - */ - @SuppressWarnings("unchecked") - private static TestConfig parseYamlToConfig(Map yamlData) { - TestConfig config = new TestConfig(); - - // Parse data_sizes - if (yamlData.containsKey("data_sizes")) { - Map dataSizesMap = (Map) yamlData.get("data_sizes"); - DataSizes dataSizes = new DataSizes(); - dataSizes.setSmall((List) dataSizesMap.get("small")); - dataSizes.setMedium((List) dataSizesMap.get("medium")); - dataSizes.setLarge((List) dataSizesMap.get("large")); - config.setDataSizes(dataSizes); - } - - // Parse iterations - if (yamlData.containsKey("iterations")) { - Map iterationsMap = (Map) yamlData.get("iterations"); - Iterations iterations = new Iterations(); - iterations.setWarmup((Integer) iterationsMap.get("warmup")); - iterations.setMeasurement((Integer) iterationsMap.get("measurement")); - config.setIterations(iterations); - } - - // Parse concurrency_levels - if (yamlData.containsKey("concurrency_levels")) { - config.setConcurrencyLevels((List) yamlData.get("concurrency_levels")); - } - - // Parse quick_config - if (yamlData.containsKey("quick_config")) { - Map quickConfigMap = (Map) yamlData.get("quick_config"); - QuickConfig quickConfig = new QuickConfig(); - - // Parse quick_config data_sizes - if (quickConfigMap.containsKey("data_sizes")) { - Map quickDataSizesMap = (Map) quickConfigMap.get("data_sizes"); - DataSizes quickDataSizes = new DataSizes(); - quickDataSizes.setSmall((List) quickDataSizesMap.get("small")); - quickConfig.setDataSizes(quickDataSizes); - } - - // Parse quick_config iterations - if (quickConfigMap.containsKey("iterations")) { - Map quickIterationsMap = (Map) quickConfigMap.get("iterations"); - Iterations quickIterations = new Iterations(); - quickIterations.setWarmup((Integer) quickIterationsMap.get("warmup")); - quickIterations.setMeasurement((Integer) quickIterationsMap.get("measurement")); - quickConfig.setIterations(quickIterations); - } - - // Parse quick_config concurrency_levels and test_types - if (quickConfigMap.containsKey("concurrency_levels")) { - quickConfig.setConcurrencyLevels((List) quickConfigMap.get("concurrency_levels")); - } - if (quickConfigMap.containsKey("test_types")) { - quickConfig.setTestTypes((List) quickConfigMap.get("test_types")); - } - - config.setQuickConfig(quickConfig); - } - - // Parse table_name and keyring - config.setTableName((String) yamlData.get("table_name")); - config.setKeyring((String) yamlData.get("keyring")); - - return config; - } - - /** - * Adjusts configuration for quick test mode. - */ - public void adjustForQuickTest() { - if (quickConfig == null) { - throw new IllegalStateException("Quick mode requested but no quick_config found in config file"); - } - - // Apply quick config settings - this.iterations.setMeasurement(quickConfig.getIterations().getMeasurement()); - this.iterations.setWarmup(quickConfig.getIterations().getWarmup()); - - // Replace data sizes with quick config - if (quickConfig.getDataSizes() != null) { - this.dataSizes.setSmall(quickConfig.getDataSizes().getSmall()); - this.dataSizes.setMedium(List.of()); // Empty list - this.dataSizes.setLarge(List.of()); // Empty list - } - - // Replace concurrency levels - if (quickConfig.getConcurrencyLevels() != null) { - this.concurrencyLevels = quickConfig.getConcurrencyLevels(); - } + private List testTypes; + + public DataSizes getDataSizes() { + return dataSizes; + } + + public void setDataSizes(DataSizes dataSizes) { + this.dataSizes = dataSizes; + } + + public Iterations getIterations() { + return iterations; + } + + public void setIterations(Iterations iterations) { + this.iterations = iterations; + } + + public List getConcurrencyLevels() { + return concurrencyLevels; + } + + public void setConcurrencyLevels(List concurrencyLevels) { + this.concurrencyLevels = concurrencyLevels; + } + + public List getTestTypes() { + return testTypes; + } + + public void setTestTypes(List testTypes) { + this.testTypes = testTypes; + } + } + + // Main getters and setters + public DataSizes getDataSizes() { + return dataSizes; + } + + public void setDataSizes(DataSizes dataSizes) { + this.dataSizes = dataSizes; + } + + public Iterations getIterations() { + return iterations; + } + + public void setIterations(Iterations iterations) { + this.iterations = iterations; + } + + public List getConcurrencyLevels() { + return concurrencyLevels; + } + + public void setConcurrencyLevels(List concurrencyLevels) { + this.concurrencyLevels = concurrencyLevels; + } + + public QuickConfig getQuickConfig() { + return quickConfig; + } + + public void setQuickConfig(QuickConfig quickConfig) { + this.quickConfig = quickConfig; + } + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getKeyring() { + return keyring; + } + + public void setKeyring(String keyring) { + this.keyring = keyring; + } + + /** + * Loads test configuration from YAML file. + */ + public static TestConfig loadConfig(String configPath) throws IOException { + Yaml yaml = new Yaml(); + try (FileInputStream fis = new FileInputStream(configPath)) { + Map yamlData = yaml.load(fis); + return parseYamlToConfig(yamlData); + } + } + + /** + * Parses the YAML data structure into TestConfig object. + */ + @SuppressWarnings("unchecked") + private static TestConfig parseYamlToConfig(Map yamlData) { + TestConfig config = new TestConfig(); + + // Parse data_sizes + if (yamlData.containsKey("data_sizes")) { + Map dataSizesMap = (Map) yamlData.get( + "data_sizes" + ); + DataSizes dataSizes = new DataSizes(); + dataSizes.setSmall((List) dataSizesMap.get("small")); + dataSizes.setMedium((List) dataSizesMap.get("medium")); + dataSizes.setLarge((List) dataSizesMap.get("large")); + config.setDataSizes(dataSizes); + } + + // Parse iterations + if (yamlData.containsKey("iterations")) { + Map iterationsMap = (Map) yamlData.get( + "iterations" + ); + Iterations iterations = new Iterations(); + iterations.setWarmup((Integer) iterationsMap.get("warmup")); + iterations.setMeasurement((Integer) iterationsMap.get("measurement")); + config.setIterations(iterations); + } + + // Parse concurrency_levels + if (yamlData.containsKey("concurrency_levels")) { + config.setConcurrencyLevels( + (List) yamlData.get("concurrency_levels") + ); + } + + // Parse quick_config + if (yamlData.containsKey("quick_config")) { + Map quickConfigMap = (Map) yamlData.get( + "quick_config" + ); + QuickConfig quickConfig = new QuickConfig(); + + // Parse quick_config data_sizes + if (quickConfigMap.containsKey("data_sizes")) { + Map quickDataSizesMap = (Map< + String, + Object + >) quickConfigMap.get("data_sizes"); + DataSizes quickDataSizes = new DataSizes(); + quickDataSizes.setSmall((List) quickDataSizesMap.get("small")); + quickConfig.setDataSizes(quickDataSizes); + } + + // Parse quick_config iterations + if (quickConfigMap.containsKey("iterations")) { + Map quickIterationsMap = (Map< + String, + Object + >) quickConfigMap.get("iterations"); + Iterations quickIterations = new Iterations(); + quickIterations.setWarmup((Integer) quickIterationsMap.get("warmup")); + quickIterations.setMeasurement( + (Integer) quickIterationsMap.get("measurement") + ); + quickConfig.setIterations(quickIterations); + } + + // Parse quick_config concurrency_levels and test_types + if (quickConfigMap.containsKey("concurrency_levels")) { + quickConfig.setConcurrencyLevels( + (List) quickConfigMap.get("concurrency_levels") + ); + } + if (quickConfigMap.containsKey("test_types")) { + quickConfig.setTestTypes( + (List) quickConfigMap.get("test_types") + ); + } + + config.setQuickConfig(quickConfig); + } + + // Parse table_name and keyring + config.setTableName((String) yamlData.get("table_name")); + config.setKeyring((String) yamlData.get("keyring")); + + return config; + } + + /** + * Adjusts configuration for quick test mode. + */ + public void adjustForQuickTest() { + if (quickConfig == null) { + throw new IllegalStateException( + "Quick mode requested but no quick_config found in config file" + ); + } + + // Apply quick config settings + this.iterations.setMeasurement( + quickConfig.getIterations().getMeasurement() + ); + this.iterations.setWarmup(quickConfig.getIterations().getWarmup()); + + // Replace data sizes with quick config + if (quickConfig.getDataSizes() != null) { + this.dataSizes.setSmall(quickConfig.getDataSizes().getSmall()); + this.dataSizes.setMedium(List.of()); // Empty list + this.dataSizes.setLarge(List.of()); // Empty list + } + + // Replace concurrency levels + if (quickConfig.getConcurrencyLevels() != null) { + this.concurrencyLevels = quickConfig.getConcurrencyLevels(); } + } } diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java index 0d70b7b421..95ac7316bd 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Utils.java @@ -15,193 +15,210 @@ * Utility functions for benchmark operations. */ public class Utils { - - private static final SecureRandom RANDOM = new SecureRandom(); - private static final DateTimeFormatter TIMESTAMP_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - /** - * Calculates the average of a list of double values. - */ - public static double average(List values) { - if (values.isEmpty()) { - return 0.0; - } - return values.stream().mapToDouble(Double::doubleValue).average().orElse(0.0); - } - - /** - * Calculates the average of an array of double values. - */ - public static double average(double[] values) { - if (values.length == 0) { - return 0.0; - } - return Arrays.stream(values).average().orElse(0.0); - } - - /** - * Calculates the specified percentile from a sorted array of values. - * - * @param sortedValues Sorted array of values - * @param percentile Percentile to calculate (0.0 to 1.0) - * @return The percentile value - */ - public static double percentile(double[] sortedValues, double percentile) { - if (sortedValues.length == 0) { - return 0.0; - } - if (percentile <= 0.0) { - return sortedValues[0]; - } - if (percentile >= 1.0) { - return sortedValues[sortedValues.length - 1]; - } - - double index = percentile * (sortedValues.length - 1); - int lower = (int) Math.floor(index); - int upper = (int) Math.ceil(index); - - if (lower == upper) { - return sortedValues[lower]; - } - - double weight = index - lower; - return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight; - } - - /** - * Generates random test data of specified size. - * - * @param size Size in bytes - * @return Random byte array - */ - public static byte[] generateTestData(int size) { - byte[] data = new byte[size]; - RANDOM.nextBytes(data); - return data; - } - - /** - * Gets the current timestamp in the format used by the Go implementation. - */ - public static String getCurrentTimestamp() { - return LocalDateTime.now().format(TIMESTAMP_FORMAT); - } - - /** - * Gets the Java version string. - */ - public static String getJavaVersion() { - return System.getProperty("java.version"); - } - - /** - * Gets the number of available CPU cores. - */ - public static int getCpuCount() { - return Runtime.getRuntime().availableProcessors(); - } - - /** - * Gets the total system memory in GB. - */ - public static double getTotalMemoryGb() { - MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); - long maxMemory = memoryMXBean.getHeapMemoryUsage().getMax(); - if (maxMemory == -1) { - // If max heap is not set, use the current committed memory as approximation - maxMemory = memoryMXBean.getHeapMemoryUsage().getCommitted(); - } - return maxMemory / (1024.0 * 1024.0 * 1024.0); - } - /** - * Gets the current memory usage in MB. - */ - public static double getCurrentMemoryUsageMb() { - MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); - long usedMemory = memoryMXBean.getHeapMemoryUsage().getUsed(); - return usedMemory / (1024.0 * 1024.0); - } - - /** - * Forces garbage collection and waits a short time for it to settle. - */ - public static void forceGcAndWait() { - System.gc(); - try { - Thread.sleep(5); // 5ms settle time, matching Go's GCSettleTimeMs - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - /** - * Converts milliseconds to seconds. - */ - public static double msToSeconds(double milliseconds) { - return milliseconds / 1000.0; - } - - /** - * Converts nanoseconds to milliseconds. - */ - public static double nanosToMillis(long nanoseconds) { - return nanoseconds / 1_000_000.0; - } - - /** - * Checks if a test type should be run based on quick config test types. - * - * @param testType The test type to check - * @param allowedTypes List of allowed test types (null means all are allowed) - * @return true if the test should run - */ - public static boolean shouldRunTestType(String testType, List allowedTypes) { - if (allowedTypes == null || allowedTypes.isEmpty()) { - return true; - } - return allowedTypes.contains(testType); - } - - /** - * Formats a double value to 2 decimal places. - */ - public static String formatDouble(double value) { - return String.format("%.2f", value); - } - - /** - * Formats bytes per second to a human-readable format. - */ - public static String formatBytesPerSecond(double bytesPerSecond) { - if (bytesPerSecond >= 1_000_000_000) { - return String.format("%.2f GB/sec", bytesPerSecond / 1_000_000_000); - } else if (bytesPerSecond >= 1_000_000) { - return String.format("%.2f MB/sec", bytesPerSecond / 1_000_000); - } else if (bytesPerSecond >= 1_000) { - return String.format("%.2f KB/sec", bytesPerSecond / 1_000); - } else { - return String.format("%.2f B/sec", bytesPerSecond); - } - } - - /** - * Memory sample class for continuous memory monitoring. - */ - public static class MemorySample { - private final long timestamp; - private final double heapMb; - private final double allocatedMb; - - public MemorySample(long timestamp, double heapMb, double allocatedMb) { - this.timestamp = timestamp; - this.heapMb = heapMb; - this.allocatedMb = allocatedMb; - } - - public long getTimestamp() { return timestamp; } - public double getHeapMb() { return heapMb; } - public double getAllocatedMb() { return allocatedMb; } - } + private static final SecureRandom RANDOM = new SecureRandom(); + private static final DateTimeFormatter TIMESTAMP_FORMAT = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + /** + * Calculates the average of a list of double values. + */ + public static double average(List values) { + if (values.isEmpty()) { + return 0.0; + } + return values + .stream() + .mapToDouble(Double::doubleValue) + .average() + .orElse(0.0); + } + + /** + * Calculates the average of an array of double values. + */ + public static double average(double[] values) { + if (values.length == 0) { + return 0.0; + } + return Arrays.stream(values).average().orElse(0.0); + } + + /** + * Calculates the specified percentile from a sorted array of values. + * + * @param sortedValues Sorted array of values + * @param percentile Percentile to calculate (0.0 to 1.0) + * @return The percentile value + */ + public static double percentile(double[] sortedValues, double percentile) { + if (sortedValues.length == 0) { + return 0.0; + } + if (percentile <= 0.0) { + return sortedValues[0]; + } + if (percentile >= 1.0) { + return sortedValues[sortedValues.length - 1]; + } + + double index = percentile * (sortedValues.length - 1); + int lower = (int) Math.floor(index); + int upper = (int) Math.ceil(index); + + if (lower == upper) { + return sortedValues[lower]; + } + + double weight = index - lower; + return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight; + } + + /** + * Generates random test data of specified size. + * + * @param size Size in bytes + * @return Random byte array + */ + public static byte[] generateTestData(int size) { + byte[] data = new byte[size]; + RANDOM.nextBytes(data); + return data; + } + + /** + * Gets the current timestamp in the format used by the Go implementation. + */ + public static String getCurrentTimestamp() { + return LocalDateTime.now().format(TIMESTAMP_FORMAT); + } + + /** + * Gets the Java version string. + */ + public static String getJavaVersion() { + return System.getProperty("java.version"); + } + + /** + * Gets the number of available CPU cores. + */ + public static int getCpuCount() { + return Runtime.getRuntime().availableProcessors(); + } + + /** + * Gets the total system memory in GB. + */ + public static double getTotalMemoryGb() { + MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); + long maxMemory = memoryMXBean.getHeapMemoryUsage().getMax(); + if (maxMemory == -1) { + // If max heap is not set, use the current committed memory as approximation + maxMemory = memoryMXBean.getHeapMemoryUsage().getCommitted(); + } + return maxMemory / (1024.0 * 1024.0 * 1024.0); + } + + /** + * Gets the current memory usage in MB. + */ + public static double getCurrentMemoryUsageMb() { + MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); + long usedMemory = memoryMXBean.getHeapMemoryUsage().getUsed(); + return usedMemory / (1024.0 * 1024.0); + } + + /** + * Forces garbage collection and waits a short time for it to settle. + */ + public static void forceGcAndWait() { + System.gc(); + try { + Thread.sleep(5); // 5ms settle time, matching Go's GCSettleTimeMs + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + + /** + * Converts milliseconds to seconds. + */ + public static double msToSeconds(double milliseconds) { + return milliseconds / 1000.0; + } + + /** + * Converts nanoseconds to milliseconds. + */ + public static double nanosToMillis(long nanoseconds) { + return nanoseconds / 1_000_000.0; + } + + /** + * Checks if a test type should be run based on quick config test types. + * + * @param testType The test type to check + * @param allowedTypes List of allowed test types (null means all are allowed) + * @return true if the test should run + */ + public static boolean shouldRunTestType( + String testType, + List allowedTypes + ) { + if (allowedTypes == null || allowedTypes.isEmpty()) { + return true; + } + return allowedTypes.contains(testType); + } + + /** + * Formats a double value to 2 decimal places. + */ + public static String formatDouble(double value) { + return String.format("%.2f", value); + } + + /** + * Formats bytes per second to a human-readable format. + */ + public static String formatBytesPerSecond(double bytesPerSecond) { + if (bytesPerSecond >= 1_000_000_000) { + return String.format("%.2f GB/sec", bytesPerSecond / 1_000_000_000); + } else if (bytesPerSecond >= 1_000_000) { + return String.format("%.2f MB/sec", bytesPerSecond / 1_000_000); + } else if (bytesPerSecond >= 1_000) { + return String.format("%.2f KB/sec", bytesPerSecond / 1_000); + } else { + return String.format("%.2f B/sec", bytesPerSecond); + } + } + + /** + * Memory sample class for continuous memory monitoring. + */ + public static class MemorySample { + + private final long timestamp; + private final double heapMb; + private final double allocatedMb; + + public MemorySample(long timestamp, double heapMb, double allocatedMb) { + this.timestamp = timestamp; + this.heapMb = heapMb; + this.allocatedMb = allocatedMb; + } + + public long getTimestamp() { + return timestamp; + } + + public double getHeapMb() { + return heapMb; + } + + public double getAllocatedMb() { + return allocatedMb; + } + } } diff --git a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json index 76e551d852..102a32cd4b 100644 --- a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json +++ b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json @@ -1,68 +1,72 @@ { - "metadata" : { - "total_memory_gb" : 12.0, - "java_version" : "17.0.16", - "language" : "java", - "total_tests" : 3, - "timestamp" : "2026-01-21 13:01:52", - "cpu_count" : 14 + "metadata": { + "total_memory_gb": 12.0, + "java_version": "17.0.16", + "language": "java", + "total_tests": 3, + "timestamp": "2026-01-21 13:01:52", + "cpu_count": 14 }, - "results" : [ { - "test_name" : "throughput", - "language" : "java", - "data_size" : 102400, - "concurrency" : 1, - "put_latency_ms" : 5.614888666666666, - "get_latency_ms" : 5.1142639999999995, - "end_to_end_latency_ms" : 10.820486333333333, - "ops_per_second" : 92.39333382096481, - "bytes_per_second" : 9461077.383266797, - "peak_memory_mb" : 0.0, - "memory_efficiency_ratio" : 0.0, - "p50_latency" : 10.601417, - "p95_latency" : 11.297454499999999, - "p99_latency" : 11.3593245, - "timestamp" : "2026-01-21 13:01:52", - "java_version" : "17.0.16", - "cpu_count" : 14, - "total_memory_gb" : 12.0 - }, { - "test_name" : "memory", - "language" : "java", - "data_size" : 102400, - "concurrency" : 1, - "put_latency_ms" : 0.0, - "get_latency_ms" : 0.0, - "end_to_end_latency_ms" : 0.0, - "ops_per_second" : 0.0, - "bytes_per_second" : 0.0, - "peak_memory_mb" : 4.139717102050781, - "memory_efficiency_ratio" : 0.023590078160563657, - "p50_latency" : 0.0, - "p95_latency" : 0.0, - "p99_latency" : 0.0, - "timestamp" : "2026-01-21 13:01:52", - "java_version" : "17.0.16", - "cpu_count" : 14, - "total_memory_gb" : 12.0 - }, { - "test_name" : "concurrent", - "language" : "java", - "data_size" : 102400, - "concurrency" : 2, - "put_latency_ms" : 0.0, - "get_latency_ms" : 0.0, - "end_to_end_latency_ms" : 10.5485459, - "ops_per_second" : 183.32981951179266, - "bytes_per_second" : 1.877297351800757E7, - "peak_memory_mb" : 0.0, - "memory_efficiency_ratio" : 0.0, - "p50_latency" : 10.253563, - "p95_latency" : 12.205531099999998, - "p99_latency" : 12.23560622, - "timestamp" : "2026-01-21 13:01:52", - "java_version" : "17.0.16", - "cpu_count" : 14, - "total_memory_gb" : 12.0 - } ] -} \ No newline at end of file + "results": [ + { + "test_name": "throughput", + "language": "java", + "data_size": 102400, + "concurrency": 1, + "put_latency_ms": 5.614888666666666, + "get_latency_ms": 5.1142639999999995, + "end_to_end_latency_ms": 10.820486333333333, + "ops_per_second": 92.39333382096481, + "bytes_per_second": 9461077.383266797, + "peak_memory_mb": 0.0, + "memory_efficiency_ratio": 0.0, + "p50_latency": 10.601417, + "p95_latency": 11.297454499999999, + "p99_latency": 11.3593245, + "timestamp": "2026-01-21 13:01:52", + "java_version": "17.0.16", + "cpu_count": 14, + "total_memory_gb": 12.0 + }, + { + "test_name": "memory", + "language": "java", + "data_size": 102400, + "concurrency": 1, + "put_latency_ms": 0.0, + "get_latency_ms": 0.0, + "end_to_end_latency_ms": 0.0, + "ops_per_second": 0.0, + "bytes_per_second": 0.0, + "peak_memory_mb": 4.139717102050781, + "memory_efficiency_ratio": 0.023590078160563657, + "p50_latency": 0.0, + "p95_latency": 0.0, + "p99_latency": 0.0, + "timestamp": "2026-01-21 13:01:52", + "java_version": "17.0.16", + "cpu_count": 14, + "total_memory_gb": 12.0 + }, + { + "test_name": "concurrent", + "language": "java", + "data_size": 102400, + "concurrency": 2, + "put_latency_ms": 0.0, + "get_latency_ms": 0.0, + "end_to_end_latency_ms": 10.5485459, + "ops_per_second": 183.32981951179266, + "bytes_per_second": 1.877297351800757e7, + "peak_memory_mb": 0.0, + "memory_efficiency_ratio": 0.0, + "p50_latency": 10.253563, + "p95_latency": 12.205531099999998, + "p99_latency": 12.23560622, + "timestamp": "2026-01-21 13:01:52", + "java_version": "17.0.16", + "cpu_count": 14, + "total_memory_gb": 12.0 + } + ] +} From 59a1d7329d4e821a1315a3ab7f6c111b5c6d897a Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 13:29:09 -0800 Subject: [PATCH 06/12] m --- .github/workflows/performance-benchmarks-java.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/performance-benchmarks-java.yml b/.github/workflows/performance-benchmarks-java.yml index 1e46775856..925c2f82f5 100644 --- a/.github/workflows/performance-benchmarks-java.yml +++ b/.github/workflows/performance-benchmarks-java.yml @@ -24,7 +24,7 @@ on: default: false type: boolean jobs: - testGo: + testJava: strategy: fail-fast: false matrix: From 2dedf7f83a43cc6ed056f608c693dba19bf1a881 Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 13:54:04 -0800 Subject: [PATCH 07/12] m --- .github/workflows/performance-benchmarks-java.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/performance-benchmarks-java.yml b/.github/workflows/performance-benchmarks-java.yml index 925c2f82f5..39629ac38a 100644 --- a/.github/workflows/performance-benchmarks-java.yml +++ b/.github/workflows/performance-benchmarks-java.yml @@ -98,6 +98,7 @@ jobs: # This works because `node` is installed by default on GHA runners CORES=$(node -e 'console.log(os.cpus().length)') make build_java CORES=$CORES + make mvn_local_deploy - name: Run Performance Benchmarks - Quick Mode shell: bash From ead4aac41b5316d38f0ac85ddc402253c7b35560 Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 15:09:49 -0800 Subject: [PATCH 08/12] fix java8 failures --- .../benchmarks/java/build.gradle.kts | 3 + .../dbesdk/benchmark/DBESDKBenchmark.java | 42 ++++-- .../com/amazon/dbesdk/benchmark/Program.java | 2 +- .../amazon/dbesdk/benchmark/TestConfig.java | 4 +- .../results/raw-data/java_results.json | 136 +++++++++--------- 5 files changed, 104 insertions(+), 83 deletions(-) diff --git a/db-esdk-performance-testing/benchmarks/java/build.gradle.kts b/db-esdk-performance-testing/benchmarks/java/build.gradle.kts index c2d755e687..c8c4ca755e 100644 --- a/db-esdk-performance-testing/benchmarks/java/build.gradle.kts +++ b/db-esdk-performance-testing/benchmarks/java/build.gradle.kts @@ -27,6 +27,9 @@ var dafnyRuntimeJavaVersion = props.getProperty("dafnyRuntimeJavaVersion") var smithyDafnyJavaConversionVersion = props.getProperty("smithyDafnyJavaConversionVersion") +java { + toolchain.languageVersion.set(JavaLanguageVersion.of(8)) +} application { mainClass.set("com.amazon.dbesdk.benchmark.Program") diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java index dc020eddcc..9ee806da62 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java @@ -267,8 +267,8 @@ private void runMemoryTests(List dataSizes) throws Exception { * Gets the total allocated bytes for the current thread. */ private static long getTotalAllocatedBytes() { - final var threadBean = ManagementFactory.getThreadMXBean(); - final var sunThreadBean = (com.sun.management.ThreadMXBean) threadBean; + final Object threadBean = ManagementFactory.getThreadMXBean(); + final com.sun.management.ThreadMXBean sunThreadBean = (com.sun.management.ThreadMXBean) threadBean; if (!sunThreadBean.isThreadAllocatedMemoryEnabled()) { sunThreadBean.setThreadAllocatedMemoryEnabled(true); @@ -731,14 +731,36 @@ private static class LatencyResult { } } - // Helper records for enhanced memory testing - private record IterationResult( - double peakMemory, - double totalAllocs, - double avgMemory - ) {} + // Helper classes for enhanced memory testing + private static class IterationResult { + final double peakMemory; + final double totalAllocs; + final double avgMemory; - private record MemoryResults(double peakMemoryMb, double avgMemoryMb) {} + IterationResult(double peakMemory, double totalAllocs, double avgMemory) { + this.peakMemory = peakMemory; + this.totalAllocs = totalAllocs; + this.avgMemory = avgMemory; + } + } + + private static class MemoryResults { + final double peakMemoryMb; + final double avgMemoryMb; - private record EnhancedMemorySample(double heapMB, double allocsMB) {} + MemoryResults(double peakMemoryMb, double avgMemoryMb) { + this.peakMemoryMb = peakMemoryMb; + this.avgMemoryMb = avgMemoryMb; + } + } + + private static class EnhancedMemorySample { + final double heapMB; + final double allocsMB; + + EnhancedMemorySample(double heapMB, double allocsMB) { + this.heapMB = heapMB; + this.allocsMB = allocsMB; + } + } } diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java index 36b315c1b4..1f39a3caa3 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java @@ -187,7 +187,7 @@ private static void printTestTypeSummary( List testResults = results .stream() .filter(r -> testType.equals(r.getTestName())) - .toList(); + .collect(java.util.stream.Collectors.toList()); if (testResults.isEmpty()) { return; diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java index 1e8528db94..5caa9383b0 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/TestConfig.java @@ -285,8 +285,8 @@ public void adjustForQuickTest() { // Replace data sizes with quick config if (quickConfig.getDataSizes() != null) { this.dataSizes.setSmall(quickConfig.getDataSizes().getSmall()); - this.dataSizes.setMedium(List.of()); // Empty list - this.dataSizes.setLarge(List.of()); // Empty list + this.dataSizes.setMedium(java.util.Collections.emptyList()); // Empty list + this.dataSizes.setLarge(java.util.Collections.emptyList()); // Empty list } // Replace concurrency levels diff --git a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json index 102a32cd4b..e0303697cf 100644 --- a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json +++ b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json @@ -1,72 +1,68 @@ { - "metadata": { - "total_memory_gb": 12.0, - "java_version": "17.0.16", - "language": "java", - "total_tests": 3, - "timestamp": "2026-01-21 13:01:52", - "cpu_count": 14 + "metadata" : { + "total_memory_gb" : 10.6669921875, + "java_version" : "1.8.0_482", + "language" : "java", + "total_tests" : 3, + "timestamp" : "2026-01-21 15:09:19", + "cpu_count" : 14 }, - "results": [ - { - "test_name": "throughput", - "language": "java", - "data_size": 102400, - "concurrency": 1, - "put_latency_ms": 5.614888666666666, - "get_latency_ms": 5.1142639999999995, - "end_to_end_latency_ms": 10.820486333333333, - "ops_per_second": 92.39333382096481, - "bytes_per_second": 9461077.383266797, - "peak_memory_mb": 0.0, - "memory_efficiency_ratio": 0.0, - "p50_latency": 10.601417, - "p95_latency": 11.297454499999999, - "p99_latency": 11.3593245, - "timestamp": "2026-01-21 13:01:52", - "java_version": "17.0.16", - "cpu_count": 14, - "total_memory_gb": 12.0 - }, - { - "test_name": "memory", - "language": "java", - "data_size": 102400, - "concurrency": 1, - "put_latency_ms": 0.0, - "get_latency_ms": 0.0, - "end_to_end_latency_ms": 0.0, - "ops_per_second": 0.0, - "bytes_per_second": 0.0, - "peak_memory_mb": 4.139717102050781, - "memory_efficiency_ratio": 0.023590078160563657, - "p50_latency": 0.0, - "p95_latency": 0.0, - "p99_latency": 0.0, - "timestamp": "2026-01-21 13:01:52", - "java_version": "17.0.16", - "cpu_count": 14, - "total_memory_gb": 12.0 - }, - { - "test_name": "concurrent", - "language": "java", - "data_size": 102400, - "concurrency": 2, - "put_latency_ms": 0.0, - "get_latency_ms": 0.0, - "end_to_end_latency_ms": 10.5485459, - "ops_per_second": 183.32981951179266, - "bytes_per_second": 1.877297351800757e7, - "peak_memory_mb": 0.0, - "memory_efficiency_ratio": 0.0, - "p50_latency": 10.253563, - "p95_latency": 12.205531099999998, - "p99_latency": 12.23560622, - "timestamp": "2026-01-21 13:01:52", - "java_version": "17.0.16", - "cpu_count": 14, - "total_memory_gb": 12.0 - } - ] -} + "results" : [ { + "test_name" : "throughput", + "language" : "java", + "data_size" : 102400, + "concurrency" : 1, + "put_latency_ms" : 11.574638666666667, + "get_latency_ms" : 5.844555333333333, + "end_to_end_latency_ms" : 17.498417, + "ops_per_second" : 57.139728062510855, + "bytes_per_second" : 5851108.153601112, + "peak_memory_mb" : 0.0, + "memory_efficiency_ratio" : 0.0, + "p50_latency" : 17.858042, + "p95_latency" : 20.8164923, + "p99_latency" : 21.07946566, + "timestamp" : "2026-01-21 15:09:18", + "java_version" : "1.8.0_482", + "cpu_count" : 14, + "total_memory_gb" : 10.6669921875 + }, { + "test_name" : "memory", + "language" : "java", + "data_size" : 102400, + "concurrency" : 1, + "put_latency_ms" : 0.0, + "get_latency_ms" : 0.0, + "end_to_end_latency_ms" : 0.0, + "ops_per_second" : 0.0, + "bytes_per_second" : 0.0, + "peak_memory_mb" : 7.449180603027344, + "memory_efficiency_ratio" : 0.013109663358183657, + "p50_latency" : 0.0, + "p95_latency" : 0.0, + "p99_latency" : 0.0, + "timestamp" : "2026-01-21 15:09:19", + "java_version" : "1.8.0_482", + "cpu_count" : 14, + "total_memory_gb" : 10.6669921875 + }, { + "test_name" : "concurrent", + "language" : "java", + "data_size" : 102400, + "concurrency" : 2, + "put_latency_ms" : 0.0, + "get_latency_ms" : 0.0, + "end_to_end_latency_ms" : 12.239991700000001, + "ops_per_second" : 157.58216515310573, + "bytes_per_second" : 1.6136413711678028E7, + "peak_memory_mb" : 0.0, + "memory_efficiency_ratio" : 0.0, + "p50_latency" : 11.595125, + "p95_latency" : 15.258908700000001, + "p99_latency" : 15.265148940000001, + "timestamp" : "2026-01-21 15:09:19", + "java_version" : "1.8.0_482", + "cpu_count" : 14, + "total_memory_gb" : 10.6669921875 + } ] +} \ No newline at end of file From 2857795b91386ffacc1eda7385ace3bb0613eecf Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 15:13:11 -0800 Subject: [PATCH 09/12] format --- .../dbesdk/benchmark/DBESDKBenchmark.java | 6 +- .../results/raw-data/java_results.json | 136 +++++++++--------- 2 files changed, 75 insertions(+), 67 deletions(-) diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java index 9ee806da62..3566e304a6 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java @@ -268,7 +268,8 @@ private void runMemoryTests(List dataSizes) throws Exception { */ private static long getTotalAllocatedBytes() { final Object threadBean = ManagementFactory.getThreadMXBean(); - final com.sun.management.ThreadMXBean sunThreadBean = (com.sun.management.ThreadMXBean) threadBean; + final com.sun.management.ThreadMXBean sunThreadBean = + (com.sun.management.ThreadMXBean) threadBean; if (!sunThreadBean.isThreadAllocatedMemoryEnabled()) { sunThreadBean.setThreadAllocatedMemoryEnabled(true); @@ -733,6 +734,7 @@ private static class LatencyResult { // Helper classes for enhanced memory testing private static class IterationResult { + final double peakMemory; final double totalAllocs; final double avgMemory; @@ -745,6 +747,7 @@ private static class IterationResult { } private static class MemoryResults { + final double peakMemoryMb; final double avgMemoryMb; @@ -755,6 +758,7 @@ private static class MemoryResults { } private static class EnhancedMemorySample { + final double heapMB; final double allocsMB; diff --git a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json index e0303697cf..48497462e6 100644 --- a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json +++ b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json @@ -1,68 +1,72 @@ { - "metadata" : { - "total_memory_gb" : 10.6669921875, - "java_version" : "1.8.0_482", - "language" : "java", - "total_tests" : 3, - "timestamp" : "2026-01-21 15:09:19", - "cpu_count" : 14 + "metadata": { + "total_memory_gb": 10.6669921875, + "java_version": "1.8.0_482", + "language": "java", + "total_tests": 3, + "timestamp": "2026-01-21 15:09:19", + "cpu_count": 14 }, - "results" : [ { - "test_name" : "throughput", - "language" : "java", - "data_size" : 102400, - "concurrency" : 1, - "put_latency_ms" : 11.574638666666667, - "get_latency_ms" : 5.844555333333333, - "end_to_end_latency_ms" : 17.498417, - "ops_per_second" : 57.139728062510855, - "bytes_per_second" : 5851108.153601112, - "peak_memory_mb" : 0.0, - "memory_efficiency_ratio" : 0.0, - "p50_latency" : 17.858042, - "p95_latency" : 20.8164923, - "p99_latency" : 21.07946566, - "timestamp" : "2026-01-21 15:09:18", - "java_version" : "1.8.0_482", - "cpu_count" : 14, - "total_memory_gb" : 10.6669921875 - }, { - "test_name" : "memory", - "language" : "java", - "data_size" : 102400, - "concurrency" : 1, - "put_latency_ms" : 0.0, - "get_latency_ms" : 0.0, - "end_to_end_latency_ms" : 0.0, - "ops_per_second" : 0.0, - "bytes_per_second" : 0.0, - "peak_memory_mb" : 7.449180603027344, - "memory_efficiency_ratio" : 0.013109663358183657, - "p50_latency" : 0.0, - "p95_latency" : 0.0, - "p99_latency" : 0.0, - "timestamp" : "2026-01-21 15:09:19", - "java_version" : "1.8.0_482", - "cpu_count" : 14, - "total_memory_gb" : 10.6669921875 - }, { - "test_name" : "concurrent", - "language" : "java", - "data_size" : 102400, - "concurrency" : 2, - "put_latency_ms" : 0.0, - "get_latency_ms" : 0.0, - "end_to_end_latency_ms" : 12.239991700000001, - "ops_per_second" : 157.58216515310573, - "bytes_per_second" : 1.6136413711678028E7, - "peak_memory_mb" : 0.0, - "memory_efficiency_ratio" : 0.0, - "p50_latency" : 11.595125, - "p95_latency" : 15.258908700000001, - "p99_latency" : 15.265148940000001, - "timestamp" : "2026-01-21 15:09:19", - "java_version" : "1.8.0_482", - "cpu_count" : 14, - "total_memory_gb" : 10.6669921875 - } ] -} \ No newline at end of file + "results": [ + { + "test_name": "throughput", + "language": "java", + "data_size": 102400, + "concurrency": 1, + "put_latency_ms": 11.574638666666667, + "get_latency_ms": 5.844555333333333, + "end_to_end_latency_ms": 17.498417, + "ops_per_second": 57.139728062510855, + "bytes_per_second": 5851108.153601112, + "peak_memory_mb": 0.0, + "memory_efficiency_ratio": 0.0, + "p50_latency": 17.858042, + "p95_latency": 20.8164923, + "p99_latency": 21.07946566, + "timestamp": "2026-01-21 15:09:18", + "java_version": "1.8.0_482", + "cpu_count": 14, + "total_memory_gb": 10.6669921875 + }, + { + "test_name": "memory", + "language": "java", + "data_size": 102400, + "concurrency": 1, + "put_latency_ms": 0.0, + "get_latency_ms": 0.0, + "end_to_end_latency_ms": 0.0, + "ops_per_second": 0.0, + "bytes_per_second": 0.0, + "peak_memory_mb": 7.449180603027344, + "memory_efficiency_ratio": 0.013109663358183657, + "p50_latency": 0.0, + "p95_latency": 0.0, + "p99_latency": 0.0, + "timestamp": "2026-01-21 15:09:19", + "java_version": "1.8.0_482", + "cpu_count": 14, + "total_memory_gb": 10.6669921875 + }, + { + "test_name": "concurrent", + "language": "java", + "data_size": 102400, + "concurrency": 2, + "put_latency_ms": 0.0, + "get_latency_ms": 0.0, + "end_to_end_latency_ms": 12.239991700000001, + "ops_per_second": 157.58216515310573, + "bytes_per_second": 1.6136413711678028e7, + "peak_memory_mb": 0.0, + "memory_efficiency_ratio": 0.0, + "p50_latency": 11.595125, + "p95_latency": 15.258908700000001, + "p99_latency": 15.265148940000001, + "timestamp": "2026-01-21 15:09:19", + "java_version": "1.8.0_482", + "cpu_count": 14, + "total_memory_gb": 10.6669921875 + } + ] +} From fd1853ef56a73379e635454a0f257bcf1e42b50f Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 16:25:02 -0800 Subject: [PATCH 10/12] m --- .../dbesdk/benchmark/DBESDKBenchmark.java | 94 +++++++++++++++++-- .../com/amazon/dbesdk/benchmark/Program.java | 42 ++++++++- .../results/raw-data/java_ddbec_results.json | 72 ++++++++++++++ .../results/raw-data/java_results.json | 40 ++++---- 4 files changed, 216 insertions(+), 32 deletions(-) create mode 100644 db-esdk-performance-testing/benchmarks/results/raw-data/java_ddbec_results.json diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java index 3566e304a6..bfda75631d 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/DBESDKBenchmark.java @@ -3,6 +3,8 @@ package com.amazon.dbesdk.benchmark; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DynamoDBEncryptor; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException; @@ -16,6 +18,7 @@ import java.util.concurrent.*; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.crypto.spec.SecretKeySpec; import software.amazon.awssdk.core.SdkBytes; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.DynamoDbItemEncryptor; @@ -24,6 +27,8 @@ import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.DynamoDbItemEncryptorConfig; import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemInput; import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.model.EncryptItemOutput; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.model.LegacyOverride; +import software.amazon.cryptography.dbencryptionsdk.dynamodb.model.LegacyPolicy; import software.amazon.cryptography.dbencryptionsdk.structuredencryption.model.CryptoAction; import software.amazon.cryptography.materialproviders.IKeyring; import software.amazon.cryptography.materialproviders.model.DBEAlgorithmSuiteId; @@ -44,6 +49,7 @@ public class DBESDKBenchmark { private final List results; private final int cpuCount; private final double totalMemoryGb; + private final boolean useLegacyOverride; /** * Creates a new benchmark instance. @@ -52,10 +58,23 @@ public class DBESDKBenchmark { * @throws Exception if initialization fails */ public DBESDKBenchmark(String configPath) throws Exception { + this(configPath, false); + } + + /** + * Creates a new benchmark instance with legacy override option. + * + * @param configPath Path to the YAML configuration file + * @param useLegacyOverride Whether to use legacy override for encryption/decryption + * @throws Exception if initialization fails + */ + public DBESDKBenchmark(String configPath, boolean useLegacyOverride) + throws Exception { this.config = TestConfig.loadConfig(configPath); this.results = new ArrayList<>(); this.cpuCount = Utils.getCpuCount(); this.totalMemoryGb = Utils.getTotalMemoryGb(); + this.useLegacyOverride = useLegacyOverride; // Initialize keyring this.keyring = KeyringSetup.createKeyring(config.getKeyring()); @@ -64,9 +83,10 @@ public DBESDKBenchmark(String configPath) throws Exception { this.itemEncryptor = setupItemEncryptor(); System.out.printf( - "Initialized DB-ESDK Benchmark - CPU cores: %d, Memory: %.1f GB%n", + "Initialized DB-ESDK Benchmark - CPU cores: %d, Memory: %.1f GB, Legacy override: %s%n", cpuCount, - totalMemoryGb + totalMemoryGb, + useLegacyOverride ); } @@ -86,7 +106,7 @@ private DynamoDbItemEncryptor setupItemEncryptor() throws Exception { DBEAlgorithmSuiteId algorithmSuiteId = DBEAlgorithmSuiteId.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384_SYMSIG_HMAC_SHA384; - DynamoDbItemEncryptorConfig itemEncryptorConfig = + DynamoDbItemEncryptorConfig.Builder configBuilder = DynamoDbItemEncryptorConfig .builder() .logicalTableName(config.getTableName()) @@ -95,15 +115,66 @@ private DynamoDbItemEncryptor setupItemEncryptor() throws Exception { .attributeActionsOnEncrypt(attributeActions) .keyring(keyring) .allowedUnsignedAttributePrefix(allowedUnsignedAttributePrefix) - .algorithmSuiteId(algorithmSuiteId) - .build(); + .algorithmSuiteId(algorithmSuiteId); + + // Add legacy override if requested + if (useLegacyOverride) { + LegacyOverride legacyOverride = createLegacyOverride(); + configBuilder.legacyOverride(legacyOverride); + } return DynamoDbItemEncryptor .builder() - .DynamoDbItemEncryptorConfig(itemEncryptorConfig) + .DynamoDbItemEncryptorConfig(configBuilder.build()) .build(); } + /** + * Creates a legacy override configuration for benchmarking legacy encryption clients. + */ + private LegacyOverride createLegacyOverride() throws Exception { + // Create legacy encryptor using SymmetricStaticProvider + DynamoDBEncryptor legacyEncryptor = createLegacyEncryptor(); + + // Define legacy attribute actions (matching current benchmark structure) + Map legacyActions = new HashMap<>(); + legacyActions.put("partition_key", CryptoAction.SIGN_ONLY); + legacyActions.put("sort_key", CryptoAction.SIGN_ONLY); + legacyActions.put("attribute1", CryptoAction.ENCRYPT_AND_SIGN); + legacyActions.put("attribute2", CryptoAction.SIGN_ONLY); + legacyActions.put(":attribute3", CryptoAction.DO_NOTHING); + + return LegacyOverride + .builder() + .policy(LegacyPolicy.FORCE_LEGACY_ENCRYPT_ALLOW_LEGACY_DECRYPT) + .encryptor(legacyEncryptor) + .attributeActionsOnEncrypt(legacyActions) + .build(); + } + + /** + * Creates a legacy DynamoDB encryptor using SymmetricStaticProvider. + */ + private DynamoDBEncryptor createLegacyEncryptor() throws Exception { + // Generate a 256-bit AES key for symmetric encryption + byte[] aesKey = new byte[32]; // 256 bits + new java.security.SecureRandom().nextBytes(aesKey); + + // Create AES key spec + SecretKeySpec encryptionKey = new SecretKeySpec(aesKey, "AES"); + + // Generate MAC key (can be same as encryption key for testing) + SecretKeySpec macKey = new SecretKeySpec(aesKey, "HmacSHA256"); + + // Create symmetric static provider + SymmetricStaticProvider provider = new SymmetricStaticProvider( + encryptionKey, + macKey + ); + + return DynamoDBEncryptor.getInstance(provider); + } + /** * Runs all configured benchmark tests. */ @@ -220,7 +291,7 @@ private BenchmarkResult runThroughputTest(int dataSize, int iterations) BenchmarkResult result = new BenchmarkResult( "throughput", - "java", + useLegacyOverride ? "java-ddbec-native" : "java", dataSize, 1 ); @@ -300,7 +371,12 @@ private BenchmarkResult runMemoryTest(int dataSize) throws Exception { ); } - BenchmarkResult result = new BenchmarkResult("memory", "java", dataSize, 1); + BenchmarkResult result = new BenchmarkResult( + "memory", + useLegacyOverride ? "java-ddbec-native" : "java", + dataSize, + 1 + ); result.setPeakMemoryMb(memoryResults.peakMemoryMb); result.setMemoryEfficiencyRatio( memoryResults.peakMemoryMb > 0 @@ -602,7 +678,7 @@ private BenchmarkResult runConcurrentTest( BenchmarkResult result = new BenchmarkResult( "concurrent", - "java", + useLegacyOverride ? "java-ddbec-native" : "java", dataSize, concurrency ); diff --git a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java index 1f39a3caa3..9850a000f7 100644 --- a/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java +++ b/db-esdk-performance-testing/benchmarks/java/src/main/java/com/amazon/dbesdk/benchmark/Program.java @@ -20,7 +20,10 @@ public static void main(String[] args) { try { // Initialize benchmark - DBESDKBenchmark benchmark = new DBESDKBenchmark(options.getConfigPath()); + DBESDKBenchmark benchmark = new DBESDKBenchmark( + options.getConfigPath(), + options.isLegacyOverride() + ); // Adjust config for quick test if requested if (options.isQuickTest()) { @@ -90,6 +93,16 @@ private static CommandLineOptions parseArgs(String[] args) { .build() ); + options.addOption( + Option + .builder("l") + .longOpt("legacy-override") + .desc( + "Use legacy DynamoDB Encryption Client (v2.x) for encryption/decryption" + ) + .build() + ); + options.addOption( Option.builder("h").longOpt("help").desc("Show this help message").build() ); @@ -112,8 +125,21 @@ private static CommandLineOptions parseArgs(String[] args) { "../results/raw-data/java_results.json" ); boolean quickTest = cmd.hasOption("q"); + boolean legacyOverride = cmd.hasOption("l"); + + if ( + legacyOverride && + outputPath.equals("../results/raw-data/java_results.json") + ) { + outputPath = "../results/raw-data/java_ddbec_results.json"; + } - return new CommandLineOptions(configPath, outputPath, quickTest); + return new CommandLineOptions( + configPath, + outputPath, + quickTest, + legacyOverride + ); } catch (ParseException e) { System.err.println("Error parsing command line: " + e.getMessage()); printUsage(options); @@ -139,6 +165,9 @@ private static void printUsage(Options options) { " java -jar db-esdk-benchmark.jar -c /path/to/config.yaml -o /path/to/results.json" ); System.out.println(); + System.out.println(" # Run legacy override benchmark"); + System.out.println(" java -jar db-esdk-benchmark.jar --legacy-override"); + System.out.println(); System.out.println(" # Using Gradle"); System.out.println(" ./gradlew run --args=\"--quick\""); } @@ -261,15 +290,18 @@ public static class CommandLineOptions { private final String configPath; private final String outputPath; private final boolean quickTest; + private final boolean legacyOverride; public CommandLineOptions( String configPath, String outputPath, - boolean quickTest + boolean quickTest, + boolean legacyOverride ) { this.configPath = configPath; this.outputPath = outputPath; this.quickTest = quickTest; + this.legacyOverride = legacyOverride; } public String getConfigPath() { @@ -283,5 +315,9 @@ public String getOutputPath() { public boolean isQuickTest() { return quickTest; } + + public boolean isLegacyOverride() { + return legacyOverride; + } } } diff --git a/db-esdk-performance-testing/benchmarks/results/raw-data/java_ddbec_results.json b/db-esdk-performance-testing/benchmarks/results/raw-data/java_ddbec_results.json new file mode 100644 index 0000000000..1a29302f2c --- /dev/null +++ b/db-esdk-performance-testing/benchmarks/results/raw-data/java_ddbec_results.json @@ -0,0 +1,72 @@ +{ + "metadata": { + "total_memory_gb": 10.6669921875, + "java_version": "1.8.0_482", + "language": "java", + "total_tests": 3, + "timestamp": "2026-01-21 16:23:20", + "cpu_count": 14 + }, + "results": [ + { + "test_name": "throughput", + "language": "java-ddbec-native", + "data_size": 102400, + "concurrency": 1, + "put_latency_ms": 2.2290973333333333, + "get_latency_ms": 1.6495416666666667, + "end_to_end_latency_ms": 3.966680333333333, + "ops_per_second": 251.9720381589814, + "bytes_per_second": 2.5801936707479693e7, + "peak_memory_mb": 0.0, + "memory_efficiency_ratio": 0.0, + "p50_latency": 3.805291, + "p95_latency": 4.3465663, + "p99_latency": 4.39467966, + "timestamp": "2026-01-21 16:23:19", + "java_version": "1.8.0_482", + "cpu_count": 14, + "total_memory_gb": 10.6669921875 + }, + { + "test_name": "memory", + "language": "java-ddbec-native", + "data_size": 102400, + "concurrency": 1, + "put_latency_ms": 0.0, + "get_latency_ms": 0.0, + "end_to_end_latency_ms": 0.0, + "ops_per_second": 0.0, + "bytes_per_second": 0.0, + "peak_memory_mb": 9.600547790527344, + "memory_efficiency_ratio": 0.010171945615057023, + "p50_latency": 0.0, + "p95_latency": 0.0, + "p99_latency": 0.0, + "timestamp": "2026-01-21 16:23:20", + "java_version": "1.8.0_482", + "cpu_count": 14, + "total_memory_gb": 10.6669921875 + }, + { + "test_name": "concurrent", + "language": "java-ddbec-native", + "data_size": 102400, + "concurrency": 2, + "put_latency_ms": 0.0, + "get_latency_ms": 0.0, + "end_to_end_latency_ms": 5.1141749, + "ops_per_second": 348.0394502716883, + "bytes_per_second": 3.563923970782088e7, + "peak_memory_mb": 0.0, + "memory_efficiency_ratio": 0.0, + "p50_latency": 5.042729, + "p95_latency": 7.205733299999999, + "p99_latency": 7.51881306, + "timestamp": "2026-01-21 16:23:20", + "java_version": "1.8.0_482", + "cpu_count": 14, + "total_memory_gb": 10.6669921875 + } + ] +} diff --git a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json index 48497462e6..2142353ae0 100644 --- a/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json +++ b/db-esdk-performance-testing/benchmarks/results/raw-data/java_results.json @@ -4,7 +4,7 @@ "java_version": "1.8.0_482", "language": "java", "total_tests": 3, - "timestamp": "2026-01-21 15:09:19", + "timestamp": "2026-01-21 16:22:52", "cpu_count": 14 }, "results": [ @@ -13,17 +13,17 @@ "language": "java", "data_size": 102400, "concurrency": 1, - "put_latency_ms": 11.574638666666667, - "get_latency_ms": 5.844555333333333, - "end_to_end_latency_ms": 17.498417, - "ops_per_second": 57.139728062510855, - "bytes_per_second": 5851108.153601112, + "put_latency_ms": 6.358222333333334, + "get_latency_ms": 7.6883333333333335, + "end_to_end_latency_ms": 14.125333333333332, + "ops_per_second": 70.78219182342052, + "bytes_per_second": 7248096.442718262, "peak_memory_mb": 0.0, "memory_efficiency_ratio": 0.0, - "p50_latency": 17.858042, - "p95_latency": 20.8164923, - "p99_latency": 21.07946566, - "timestamp": "2026-01-21 15:09:18", + "p50_latency": 12.222625, + "p95_latency": 18.055712200000002, + "p99_latency": 18.57420884, + "timestamp": "2026-01-21 16:22:51", "java_version": "1.8.0_482", "cpu_count": 14, "total_memory_gb": 10.6669921875 @@ -38,12 +38,12 @@ "end_to_end_latency_ms": 0.0, "ops_per_second": 0.0, "bytes_per_second": 0.0, - "peak_memory_mb": 7.449180603027344, - "memory_efficiency_ratio": 0.013109663358183657, + "peak_memory_mb": 7.44854736328125, + "memory_efficiency_ratio": 0.013110777878840024, "p50_latency": 0.0, "p95_latency": 0.0, "p99_latency": 0.0, - "timestamp": "2026-01-21 15:09:19", + "timestamp": "2026-01-21 16:22:52", "java_version": "1.8.0_482", "cpu_count": 14, "total_memory_gb": 10.6669921875 @@ -55,15 +55,15 @@ "concurrency": 2, "put_latency_ms": 0.0, "get_latency_ms": 0.0, - "end_to_end_latency_ms": 12.239991700000001, - "ops_per_second": 157.58216515310573, - "bytes_per_second": 1.6136413711678028e7, + "end_to_end_latency_ms": 12.0850042, + "ops_per_second": 159.58125877696924, + "bytes_per_second": 1.634112089876165e7, "peak_memory_mb": 0.0, "memory_efficiency_ratio": 0.0, - "p50_latency": 11.595125, - "p95_latency": 15.258908700000001, - "p99_latency": 15.265148940000001, - "timestamp": "2026-01-21 15:09:19", + "p50_latency": 11.326729, + "p95_latency": 15.798329050000001, + "p99_latency": 15.81029941, + "timestamp": "2026-01-21 16:22:52", "java_version": "1.8.0_482", "cpu_count": 14, "total_memory_gb": 10.6669921875 From 7a2d2e77ccd6fce42ecd3ba1eacac8541fb8bf22 Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 16:44:19 -0800 Subject: [PATCH 11/12] m --- .../workflows/performance-benchmarks-java.yml | 10 ++ cfn/CW-Filters.yml | 123 +++++++++++++++++- 2 files changed, 131 insertions(+), 2 deletions(-) diff --git a/.github/workflows/performance-benchmarks-java.yml b/.github/workflows/performance-benchmarks-java.yml index 39629ac38a..c8e0382aea 100644 --- a/.github/workflows/performance-benchmarks-java.yml +++ b/.github/workflows/performance-benchmarks-java.yml @@ -105,19 +105,24 @@ jobs: working-directory: ./${{matrix.benchmark-dir}}/benchmarks/java run: | ./gradlew run --args="--config ../config/test-scenarios.yaml --quick" + ./gradlew run --args="--config ../config/test-scenarios.yaml --quick --legacy-override" - name: Parse and Format Logs working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/ run: | LOG_FILE="java_results.json" + DDBEC_LOG_FILE="java_ddbec_results.json" UPLOAD_FILE="cloudwatch_logs.json" + DDBEC_UPLOAD_FILE="cloudwatch_ddbec_log.json" TIMESTAMP=$(date +%s%3N) jq -c --arg ts "$(date +%s)000" '[.results[] as $result | .metadata as $meta | {timestamp: ($ts | tonumber), message: ({metadata: $meta, result: $result} | tostring)}]' $LOG_FILE > $UPLOAD_FILE + jq -c --arg ts "$(date +%s)000" '[.results[] as $result | .metadata as $meta | {timestamp: ($ts | tonumber), message: ({metadata: $meta, result: $result} | tostring)}]' $DDBEC_LOG_FILE > $DDBEC_UPLOAD_FILE - name: Upload logs to CloudWatch working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/ run: | LOG_FILE="cloudwatch_logs.json" + DDBEC_LOG_FILE="cloudwatch_ddbec_log.json" LOG_GROUP="aws-dbesdk-performance-benchmarks" LOG_STREAM="java/${{matrix.java-version}}/quick_benchmarks/${{ github.workflow }}" @@ -130,3 +135,8 @@ jobs: --log-group-name "$LOG_GROUP" \ --log-stream-name "$LOG_STREAM" \ --log-events file://$LOG_FILE + + aws logs put-log-events \ + --log-group-name "$LOG_GROUP" \ + --log-stream-name "$LOG_STREAM" \ + --log-events file://$DDBEC_LOG_FILE diff --git a/cfn/CW-Filters.yml b/cfn/CW-Filters.yml index 6539d237a9..cc3fd2936b 100644 --- a/cfn/CW-Filters.yml +++ b/cfn/CW-Filters.yml @@ -603,6 +603,125 @@ Resources: - Key: Language Value: "$.result.language" + # Filter 1: Memory Efficiency Ratio - JavaDDBEC + JavaDDBECMemoryEfficiencyRatioFilter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.result.language = "java-ddbec-native" && $.result.test_name = "memory" }' + MetricTransformations: + - MetricName: MemoryEfficiencyRatio + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.memory_efficiency_ratio" + Dimensions: + - Key: Language + Value: "$.result.language" + + # Filter 2: Memory Usage 50MB - JavaDDBEC + JavaDDBECMemoryUsage50MBFilter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.result.language = "java-ddbec-native" && $.result.test_name = "memory" }' + MetricTransformations: + - MetricName: PeakMemoryMB + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.peak_memory_mb" + Unit: Megabytes + Dimensions: + - Key: Language + Value: "$.result.language" + + # Filter 3: DataSize 52MB P50 Latency - JavaDDBEC + JavaDDBECDataSize52MBP50LatencyFilter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.metadata.language = "java-ddbec-native" && $.result.test_name = "throughput" }' + MetricTransformations: + - MetricName: P50Latency + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.p50_latency" + Unit: Milliseconds + Dimensions: + - Key: Language + Value: "$.result.language" + + # Filter 4: DataSize 52MB P95 Latency - JavaDDBEC + JavaDDBECDataSize52MBP95LatencyFilter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.metadata.language = "java-ddbec-native" && $.result.test_name = "throughput" }' + MetricTransformations: + - MetricName: P95Latency + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.p95_latency" + Unit: Milliseconds + Dimensions: + - Key: Language + Value: "$.result.language" + + # Filter 5: DataSize 52MB P99 Latency - JavaDDBEC + JavaDDBECDataSize52MBP99LatencyFilter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.metadata.language = "java-ddbec-native" && $.result.test_name = "throughput" }' + MetricTransformations: + - MetricName: P99Latency + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.p99_latency" + Unit: Milliseconds + Dimensions: + - Key: Language + Value: "$.result.language" + + # Filter 6: Concurrency P50 - JavaDDBEC + JavaDDBECConcurrencyP50Filter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.result.language = "java-ddbec-native" && $.result.test_name = "concurrent" }' + MetricTransformations: + - MetricName: ConcurrencyP50Latency + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.p50_latency" + Unit: Milliseconds + Dimensions: + - Key: Language + Value: "$.result.language" + + # Filter 7: Concurrency P95 - JavaDDBEC + JavaDDBECConcurrencyP95Filter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.result.language = "java-ddbec-native" && $.result.test_name = "concurrent" }' + MetricTransformations: + - MetricName: ConcurrencyP95Latency + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.p95_latency" + Unit: Milliseconds + Dimensions: + - Key: Language + Value: "$.result.language" + + # Filter 8: Concurrency P99 - JavaDDBEC + JavaDDBECConcurrencyP99Filter: + Type: AWS::Logs::MetricFilter + Properties: + LogGroupName: !Ref LogGroupName + FilterPattern: '{ $.result.language = "java-ddbec-native" && $.result.test_name = "concurrent" }' + MetricTransformations: + - MetricName: ConcurrencyP99Latency + MetricNamespace: JavaDDBECPerformanceBenchmarks + MetricValue: "$.result.p99_latency" + Unit: Milliseconds + Dimensions: + - Key: Language + Value: "$.result.language" + Outputs: LogGroupName: Description: "CloudWatch Log Group Name" @@ -612,8 +731,8 @@ Outputs: TotalFiltersCreated: Description: "Total number of metric filters created" - Value: "40" + Value: "48" MetricNamespaces: Description: "CloudWatch Metrics Namespaces by Language" - Value: "JavaDBESDKPerformanceBenchmarks, NetDBESDKPerformanceBenchmarks, PythonDBESDKPerformanceBenchmarks, GoDBESDKPerformanceBenchmarks, RustDBESDKPerformanceBenchmarks" + Value: "JavaDBESDKPerformanceBenchmarks, NetDBESDKPerformanceBenchmarks, PythonDBESDKPerformanceBenchmarks, GoDBESDKPerformanceBenchmarks, RustDBESDKPerformanceBenchmarks, JavaDDBECPerformanceBenchmarks" From aa3bd48bd3726a71364859b39bff3605196deb39 Mon Sep 17 00:00:00 2001 From: Jose Corella Date: Wed, 21 Jan 2026 17:59:20 -0800 Subject: [PATCH 12/12] m --- .github/workflows/performance-benchmarks-java.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/performance-benchmarks-java.yml b/.github/workflows/performance-benchmarks-java.yml index c8e0382aea..908472bec0 100644 --- a/.github/workflows/performance-benchmarks-java.yml +++ b/.github/workflows/performance-benchmarks-java.yml @@ -135,7 +135,7 @@ jobs: --log-group-name "$LOG_GROUP" \ --log-stream-name "$LOG_STREAM" \ --log-events file://$LOG_FILE - + aws logs put-log-events \ --log-group-name "$LOG_GROUP" \ --log-stream-name "$LOG_STREAM" \