From 0009e23c7b38dff78afc7addede41fed16937976 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Wed, 23 Oct 2024 12:33:02 -0400 Subject: [PATCH] chore: improve benchmark realism; add more context (#1182) Signed-off-by: Todd Baert --- benchmark.txt | 233 +++++++++++------- .../sdk/benchmark/AllocationBenchmark.java | 16 +- 2 files changed, 159 insertions(+), 90 deletions(-) diff --git a/benchmark.txt b/benchmark.txt index 696ffa24c..d028a3f87 100644 --- a/benchmark.txt +++ b/benchmark.txt @@ -1,12 +1,15 @@ [INFO] Scanning for projects... [INFO] [INFO] ------------------------< dev.openfeature:sdk >------------------------- -[INFO] Building OpenFeature Java SDK 1.12.0 +[INFO] Building OpenFeature Java SDK 1.12.1 [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [WARNING] Parameter 'encoding' is unknown for plugin 'maven-checkstyle-plugin:3.5.0:check (validate)' +[WARNING] Parameter 'encoding' is unknown for plugin 'maven-checkstyle-plugin:3.5.0:check (validate)' +[WARNING] Parameter 'encoding' is unknown for plugin 'maven-checkstyle-plugin:3.5.0:check (validate)' [INFO] -[INFO] >>> jmh:0.2.2:benchmark (default-cli) > process-test-resources @ sdk >>> +[INFO] --- clean:3.2.0:clean (default-clean) @ sdk --- +[INFO] Deleting /home/todd/git/java-sdk/target [INFO] [INFO] --- checkstyle:3.5.0:check (validate) @ sdk --- [INFO] Starting audit... @@ -33,15 +36,67 @@ Audit done. processing is enabled explicitly (-proc:only, -proc:full). Use -Xlint:-options to suppress this message. Use -proc:none to disable annotation processing. -[WARNING] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/MutableStructure.java:[19,1] Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type. -[WARNING] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/ImmutableStructure.java:[22,1] Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type. [WARNING] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/EventDetails.java:[9,1] Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type. +[WARNING] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/ImmutableStructure.java:[22,1] Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type. +[WARNING] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/MutableStructure.java:[19,1] Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type. [WARNING] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/Value.java:[27,26] finalize() in java.lang.Object has been deprecated and marked for removal [INFO] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/NoOpProvider.java: Some input files use or override a deprecated API. [INFO] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/NoOpProvider.java: Recompile with -Xlint:deprecation for details. [INFO] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/Value.java: Some input files use unchecked or unsafe operations. [INFO] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/Value.java: Recompile with -Xlint:unchecked for details. [INFO] +[INFO] --- checkstyle:3.5.0:check (validate) @ sdk --- +[INFO] Starting audit... +Audit done. +[INFO] You have 0 Checkstyle violations. +[INFO] +[INFO] --- jacoco:0.8.12:prepare-agent (prepare-agent) @ sdk --- +[INFO] surefireArgLine set to -javaagent:/home/todd/.m2/repository/org/jacoco/org.jacoco.agent/0.8.12/org.jacoco.agent-0.8.12-runtime.jar=destfile=/home/todd/git/java-sdk/target/coverage-reports/jacoco-ut.exec +[INFO] +[INFO] --- resources:3.3.1:resources (default-resources) @ sdk --- +[INFO] skip non existing resourceDirectory /home/todd/git/java-sdk/src/main/resources +[INFO] +[INFO] --- compiler:3.13.0:compile (default-compile) @ sdk --- +[INFO] Nothing to compile - all classes are up to date. +[INFO] +[INFO] --- resources:3.3.1:testResources (default-testResources) @ sdk --- +[INFO] Copying 2 resources from src/test/resources to target/test-classes +[INFO] +[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ sdk --- +[INFO] Recompiling the module because of changed dependency. +[INFO] Compiling 52 source files with javac [debug target 1.8] to target/test-classes +[WARNING] bootstrap class path not set in conjunction with -source 8 +[WARNING] source value 8 is obsolete and will be removed in a future release +[WARNING] target value 8 is obsolete and will be removed in a future release +[WARNING] To suppress warnings about obsolete options, use -Xlint:-options. +[INFO] Annotation processing is enabled because one or more processors were found + on the class path. A future release of javac may disable annotation processing + unless at least one processor is specified by name (-processor), or a search + path is specified (--processor-path, --processor-module-path), or annotation + processing is enabled explicitly (-proc:only, -proc:full). + Use -Xlint:-options to suppress this message. + Use -proc:none to disable annotation processing. +[INFO] /home/todd/git/java-sdk/src/test/java/dev/openfeature/sdk/EventsTest.java: Some input files use or override a deprecated API. +[INFO] /home/todd/git/java-sdk/src/test/java/dev/openfeature/sdk/EventsTest.java: Recompile with -Xlint:deprecation for details. +[INFO] /home/todd/git/java-sdk/src/test/java/dev/openfeature/sdk/HookSpecTest.java: Some input files use unchecked or unsafe operations. +[INFO] /home/todd/git/java-sdk/src/test/java/dev/openfeature/sdk/HookSpecTest.java: Recompile with -Xlint:unchecked for details. +[INFO] +[INFO] >>> jmh:0.2.2:benchmark (default-cli) > process-test-resources @ sdk >>> +[INFO] +[INFO] --- checkstyle:3.5.0:check (validate) @ sdk --- +[INFO] Starting audit... +Audit done. +[INFO] You have 0 Checkstyle violations. +[INFO] +[INFO] --- jacoco:0.8.12:prepare-agent (prepare-agent) @ sdk --- +[INFO] surefireArgLine set to -javaagent:/home/todd/.m2/repository/org/jacoco/org.jacoco.agent/0.8.12/org.jacoco.agent-0.8.12-runtime.jar=destfile=/home/todd/git/java-sdk/target/coverage-reports/jacoco-ut.exec +[INFO] +[INFO] --- resources:3.3.1:resources (default-resources) @ sdk --- +[INFO] skip non existing resourceDirectory /home/todd/git/java-sdk/src/main/resources +[INFO] +[INFO] --- compiler:3.13.0:compile (default-compile) @ sdk --- +[INFO] Nothing to compile - all classes are up to date. +[INFO] [INFO] --- resources:3.3.1:testResources (default-testResources) @ sdk --- [INFO] Copying 2 resources from src/test/resources to target/test-classes [INFO] @@ -59,7 +114,7 @@ Audit done. # JMH version: 1.37 # VM version: JDK 21.0.4, OpenJDK 64-Bit Server VM, 21.0.4+7 # VM invoker: /usr/lib/jvm/java-21-openjdk/bin/java -# VM options: -Xmx1024m -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xmx1024m -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC +# VM options: -Xmx1024m -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC # Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable) # Warmup: # Measurement: 1 iterations, single-shot each @@ -74,74 +129,74 @@ Audit done. [0.001s][warning][gc,init] Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups Iteration 1: num #instances #bytes class name (module) ------------------------------------------------------- - 1: 1146984 55055232 java.util.HashMap (java.base@21.0.4) - 2: 700056 11200896 java.util.HashMap$EntrySet (java.base@21.0.4) - 3: 47757 9295888 [B (java.base@21.0.4) - 4: 305989 8105752 [Ljava.lang.Object; (java.base@21.0.4) - 5: 482225 7715600 dev.openfeature.sdk.ImmutableStructure - 6: 472225 7555600 dev.openfeature.sdk.ImmutableContext - 7: 100000 4000000 dev.openfeature.sdk.HookContext - 8: 100000 4000000 dev.openfeature.sdk.HookContext$HookContextBuilder - 9: 154 2995712 [Ljdk.internal.vm.FillerElement; (java.base@21.0.4) - 10: 122807 2947368 java.util.ArrayList (java.base@21.0.4) - 11: 50000 2000000 dev.openfeature.sdk.FlagEvaluationDetails - 12: 50000 2000000 dev.openfeature.sdk.ProviderEvaluation - 13: 50002 1600064 java.util.Collections$UnmodifiableMap (java.base@21.0.4) - 14: 100001 1600016 dev.openfeature.sdk.NoOpProvider$$Lambda/0x000074760c02fa78 - 15: 50000 1600000 [Ljava.util.List; (java.base@21.0.4) - 16: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata - 17: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata$ImmutableMetadataBuilder - 18: 100000 1600000 dev.openfeature.sdk.OpenFeatureClient$$Lambda/0x000074760c0821f8 - 19: 43808 1401856 java.util.ArrayList$Itr (java.base@21.0.4) - 20: 50000 1200000 dev.openfeature.sdk.FlagEvaluationOptions - 21: 56919 910704 java.util.Optional (java.base@21.0.4) - 22: 34754 834096 dev.openfeature.sdk.FlagEvaluationOptions$FlagEvaluationOptionsBuilder - 23: 4489 679248 [I (java.base@21.0.4) - 24: 26554 637296 java.lang.String (java.base@21.0.4) - 25: 12462 598176 dev.openfeature.sdk.FlagEvaluationDetails$FlagEvaluationDetailsBuilder - 26: 13748 549920 dev.openfeature.sdk.ProviderEvaluation$ProviderEvaluationBuilder - 27: 16418 394032 dev.openfeature.sdk.HookSupport$$Lambda/0x000074760c081230 - 28: 1461 390008 [J (java.base@21.0.4) - 29: 24033 384528 dev.openfeature.sdk.internal.AutoCloseableReentrantReadWriteLock$$Lambda/0x000074760c02eae8 - 30: 14591 350184 dev.openfeature.sdk.HookSupport$$Lambda/0x000074760c081000 - 31: 2355 288104 java.lang.Class (java.base@21.0.4) - 32: 8141 260512 java.util.HashMap$EntryIterator (java.base@21.0.4) - 33: 4610 258160 jdk.internal.org.objectweb.asm.SymbolTable$Entry (java.base@21.0.4) - 34: 10001 240024 java.lang.Double (java.base@21.0.4) - 35: 2502 180144 java.lang.reflect.Field (java.base@21.0.4) - 36: 10000 160000 dev.openfeature.sdk.Value - 37: 6004 144096 java.lang.StringBuilder (java.base@21.0.4) - 38: 179 139928 [Ljdk.internal.org.objectweb.asm.SymbolTable$Entry; (java.base@21.0.4) - 39: 3824 122368 java.util.concurrent.ConcurrentHashMap$Node (java.base@21.0.4) - 40: 48 122168 [C (java.base@21.0.4) - 41: 1440 113512 [S (java.base@21.0.4) - 42: 1201 105688 java.lang.reflect.Method (java.base@21.0.4) - 43: 3030 79616 [Ljava.lang.Class; (java.base@21.0.4) - 44: 1349 75544 jdk.internal.org.objectweb.asm.Label (java.base@21.0.4) - 45: 1550 74400 java.lang.invoke.MemberName (java.base@21.0.4) - 46: 332 74368 jdk.internal.org.objectweb.asm.MethodWriter (java.base@21.0.4) - 47: 1794 71760 java.lang.invoke.MethodType (java.base@21.0.4) - 48: 1089 69696 java.net.URL (java.base@21.0.4) - 49: 2011 64352 java.util.HashMap$Node (java.base@21.0.4) - 50: 121 50512 [Ljava.util.concurrent.ConcurrentHashMap$Node; (java.base@21.0.4) - 51: 3140 50240 jdk.internal.util.StrongReferenceKey (java.base@21.0.4) - 52: 491 49608 [Ljava.util.HashMap$Node; (java.base@21.0.4) + 1: 1407606 67565088 java.util.HashMap (java.base@21.0.4) + 2: 780500 45970160 [Ljava.util.HashMap$Node; (java.base@21.0.4) + 3: 1152020 36864640 java.util.HashMap$Node (java.base@21.0.4) + 4: 860065 13761040 java.util.HashMap$EntrySet (java.base@21.0.4) + 5: 690006 11040096 dev.openfeature.sdk.Value + 6: 47842 9731792 [B (java.base@21.0.4) + 7: 305994 8105936 [Ljava.lang.Object; (java.base@21.0.4) + 8: 360370 5765920 dev.openfeature.sdk.ImmutableStructure + 9: 350370 5605920 dev.openfeature.sdk.ImmutableContext + 10: 100000 4000000 dev.openfeature.sdk.HookContext + 11: 100000 4000000 dev.openfeature.sdk.HookContext$HookContextBuilder + 12: 116586 2798064 java.util.ArrayList (java.base@21.0.4) + 13: 174 2171368 [Ljdk.internal.vm.FillerElement; (java.base@21.0.4) + 14: 50000 2000000 dev.openfeature.sdk.FlagEvaluationDetails + 15: 50000 2000000 dev.openfeature.sdk.ProviderEvaluation + 16: 62056 1985792 java.util.HashMap$EntryIterator (java.base@21.0.4) + 17: 118262 1892192 java.util.Optional (java.base@21.0.4) + 18: 41643 1665720 dev.openfeature.sdk.ProviderEvaluation$ProviderEvaluationBuilder + 19: 50002 1600064 java.util.Collections$UnmodifiableMap (java.base@21.0.4) + 20: 100001 1600016 dev.openfeature.sdk.NoOpProvider$$Lambda/0x000070b4d802fa78 + 21: 50000 1600000 [Ljava.util.List; (java.base@21.0.4) + 22: 100000 1600000 dev.openfeature.sdk.OpenFeatureClient$$Lambda/0x000070b4d8082a18 + 23: 50000 1200000 dev.openfeature.sdk.FlagEvaluationOptions + 24: 29392 940544 java.util.ArrayList$Itr (java.base@21.0.4) + 25: 57139 914224 dev.openfeature.sdk.ImmutableMetadata + 26: 34240 821760 dev.openfeature.sdk.FlagEvaluationOptions$FlagEvaluationOptionsBuilder + 27: 48782 780512 dev.openfeature.sdk.ImmutableMetadata$ImmutableMetadataBuilder + 28: 4491 721464 [I (java.base@21.0.4) + 29: 26608 638592 java.lang.String (java.base@21.0.4) + 30: 1461 390008 [J (java.base@21.0.4) + 31: 7139 342672 dev.openfeature.sdk.FlagEvaluationDetails$FlagEvaluationDetailsBuilder + 32: 18300 292800 dev.openfeature.sdk.internal.AutoCloseableReentrantReadWriteLock$$Lambda/0x000070b4d802eae8 + 33: 2357 288328 java.lang.Class (java.base@21.0.4) + 34: 4651 260456 jdk.internal.org.objectweb.asm.SymbolTable$Entry (java.base@21.0.4) + 35: 10001 240024 java.lang.Double (java.base@21.0.4) + 36: 9315 223560 dev.openfeature.sdk.HookSupport$$Lambda/0x000070b4d8081bb8 + 37: 7921 190104 dev.openfeature.sdk.HookSupport$$Lambda/0x000070b4d8081988 + 38: 2502 180144 java.lang.reflect.Field (java.base@21.0.4) + 39: 6011 144264 java.lang.StringBuilder (java.base@21.0.4) + 40: 181 142008 [Ljdk.internal.org.objectweb.asm.SymbolTable$Entry; (java.base@21.0.4) + 41: 3829 122528 java.util.concurrent.ConcurrentHashMap$Node (java.base@21.0.4) + 42: 48 122168 [C (java.base@21.0.4) + 43: 1440 113512 [S (java.base@21.0.4) + 44: 1201 105688 java.lang.reflect.Method (java.base@21.0.4) + 45: 3035 79672 [Ljava.lang.Class; (java.base@21.0.4) + 46: 1353 75768 jdk.internal.org.objectweb.asm.Label (java.base@21.0.4) + 47: 1570 75360 java.lang.invoke.MemberName (java.base@21.0.4) + 48: 336 75264 jdk.internal.org.objectweb.asm.MethodWriter (java.base@21.0.4) + 49: 1807 72280 java.lang.invoke.MethodType (java.base@21.0.4) + 50: 1089 69696 java.net.URL (java.base@21.0.4) + 51: 3159 50544 jdk.internal.util.StrongReferenceKey (java.base@21.0.4) + 52: 121 50512 [Ljava.util.concurrent.ConcurrentHashMap$Node; (java.base@21.0.4) 53: 1057 42280 java.io.ObjectStreamField (java.base@21.0.4) 54: 1225 39200 java.io.File (java.base@21.0.4) 55: 779 37392 jdk.internal.org.objectweb.asm.Frame (java.base@21.0.4) - 56: 243 25272 java.util.jar.JarFile$JarFileEntry (java.base@21.0.4) - 57: 793 25224 [Ljava.lang.String; (java.base@21.0.4) + 56: 795 25272 [Ljava.lang.String; (java.base@21.0.4) + 57: 243 25272 java.util.jar.JarFile$JarFileEntry (java.base@21.0.4) 58: 622 24880 java.lang.NoSuchFieldException (java.base@21.0.4) 59: 571 22840 java.util.LinkedHashMap$Entry (java.base@21.0.4) - 60: 473 22704 jdk.internal.ref.CleanerImpl$PhantomCleanableRef (java.base@21.0.4) - 61: 689 22048 jdk.internal.util.WeakReferenceKey (java.base@21.0.4) - 62: 824 19776 jdk.internal.org.objectweb.asm.ByteVector (java.base@21.0.4) + 60: 475 22800 jdk.internal.ref.CleanerImpl$PhantomCleanableRef (java.base@21.0.4) + 61: 692 22144 jdk.internal.util.WeakReferenceKey (java.base@21.0.4) + 62: 832 19968 jdk.internal.org.objectweb.asm.ByteVector (java.base@21.0.4) 63: 248 18848 [Ljava.lang.ref.SoftReference; (java.base@21.0.4) - 64: 117 17784 jdk.internal.org.objectweb.asm.ClassWriter (java.base@21.0.4) + 64: 119 18088 jdk.internal.org.objectweb.asm.ClassWriter (java.base@21.0.4) 65: 380 16824 [Ljava.lang.invoke.LambdaForm$Name; (java.base@21.0.4) 66: 625 15000 java.lang.Long (java.base@21.0.4) 67: 463 14816 java.lang.invoke.LambdaForm$Name (java.base@21.0.4) - 68: 903 14448 java.lang.Object (java.base@21.0.4) + 68: 904 14464 java.lang.Object (java.base@21.0.4) 69: 198 14256 java.lang.reflect.Constructor (java.base@21.0.4) 70: 249 13944 java.util.zip.ZipFile$ZipFileInputStream (java.base@21.0.4) 71: 334 13360 jdk.internal.org.objectweb.asm.Handler (java.base@21.0.4) @@ -151,34 +206,34 @@ Iteration 1: num #instances #bytes class name (module) 75: 102 12240 java.io.ObjectStreamClass (java.base@21.0.4) 76: 249 11952 java.util.zip.ZipFile$ZipFileInflaterInputStream (java.base@21.0.4) 77: 359 11488 jdk.internal.org.objectweb.asm.Type (java.base@21.0.4) - 78: 464 11136 jdk.internal.org.objectweb.asm.Edge (java.base@21.0.4) - 79: 463 11112 java.lang.invoke.ResolvedMethodName (java.base@21.0.4) + 78: 467 11208 java.lang.invoke.ResolvedMethodName (java.base@21.0.4) + 79: 464 11136 jdk.internal.org.objectweb.asm.Edge (java.base@21.0.4) 80: 341 10912 jdk.internal.math.FDBigInteger (java.base@21.0.4) 81: 94 10728 [Ljava.lang.reflect.Field; (java.base@21.0.4) - 82: 266 10640 java.lang.NoSuchMethodException (java.base@21.0.4) - 83: 266 10640 java.security.CodeSource (java.base@21.0.4) - 84: 264 10560 sun.security.util.KnownOIDs (java.base@21.0.4) - 85: 218 10464 java.lang.invoke.DirectMethodHandle$Constructor (java.base@21.0.4) + 82: 223 10704 java.lang.invoke.DirectMethodHandle$Constructor (java.base@21.0.4) + 83: 266 10640 java.lang.NoSuchMethodException (java.base@21.0.4) + 84: 266 10640 java.security.CodeSource (java.base@21.0.4) + 85: 264 10560 sun.security.util.KnownOIDs (java.base@21.0.4) 86: 75 10200 sun.nio.fs.UnixFileAttributes (java.base@21.0.4) - 87: 123 9840 jdk.internal.event.DeserializationEvent (java.base@21.0.4) - 88: 245 9800 java.lang.ref.SoftReference (java.base@21.0.4) + 87: 245 9800 java.lang.ref.SoftReference (java.base@21.0.4) + 88: 118 9440 jdk.internal.event.DeserializationEvent (java.base@21.0.4) 89: 115 9200 [Ljava.util.WeakHashMap$Entry; (java.base@21.0.4) 90: 368 8832 java.lang.module.ModuleDescriptor$Exports (java.base@21.0.4) 91: 63 8384 [Ljava.lang.invoke.MethodHandle; (java.base@21.0.4) 92: 146 8176 java.io.FileCleanable (java.base@21.0.4) 93: 125 8000 java.lang.Class$ReflectionData (java.base@21.0.4) - 94: 322 7728 java.util.ImmutableCollections$Set12 (java.base@21.0.4) - 95: 120 7680 jdk.internal.org.objectweb.asm.SymbolTable (java.base@21.0.4) - 96: 69 7176 java.lang.invoke.InnerClassLambdaMetafactory (java.base@21.0.4) + 94: 122 7808 jdk.internal.org.objectweb.asm.SymbolTable (java.base@21.0.4) + 95: 324 7776 java.util.ImmutableCollections$Set12 (java.base@21.0.4) + 96: 71 7384 java.lang.invoke.InnerClassLambdaMetafactory (java.base@21.0.4) 97: 144 6912 jdk.internal.org.objectweb.asm.AnnotationWriter (java.base@21.0.4) 98: 167 6680 jdk.internal.loader.URLClassPath$JarLoader$2 (java.base@21.0.4) - 99: 196 6272 java.lang.invoke.MethodHandles$Lookup (java.base@21.0.4) + 99: 202 6464 java.lang.invoke.MethodHandles$Lookup (java.base@21.0.4) 100: 156 6240 java.util.StringJoiner (java.base@21.0.4) 101: 153 6120 java.io.FileDescriptor (java.base@21.0.4) 102: 126 6048 java.lang.invoke.LambdaForm (java.base@21.0.4) 103: 77 6016 [Ljava.lang.reflect.Method; (java.base@21.0.4) - 104: 249 5976 java.util.zip.ZipFile$InflaterCleanupAction (java.base@21.0.4) - 105: 370 5920 java.lang.Byte (java.base@21.0.4) + 104: 375 6000 java.lang.Byte (java.base@21.0.4) + 105: 249 5976 java.util.zip.ZipFile$InflaterCleanupAction (java.base@21.0.4) 106: 74 5920 java.util.zip.ZipFile$Source (java.base@21.0.4) 107: 82 5720 [Ljava.io.ObjectStreamField; (java.base@21.0.4) 108: 40 5640 [Ljava.lang.ClassValue$Entry; (java.base@21.0.4) @@ -193,20 +248,20 @@ Iteration 1: num #instances #bytes class name (module) 117: 301 4816 java.util.HashSet (java.base@21.0.4) 118: 75 4800 java.util.zip.Inflater (java.base@21.0.4) truncated... -Total 4474389 138762960 +Total 7264791 244216640 -0.113 s/op - +totalAllocatedBytes: 138762960.000 bytes - +totalAllocatedInstances: 4474389.000 instances +0.166 s/op + +totalAllocatedBytes: 244216640.000 bytes + +totalAllocatedInstances: 7264791.000 instances +totalHeap: 521412608.000 bytes Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalAllocatedBytes": - 138762960.000 bytes + 244216640.000 bytes Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalAllocatedInstances": - 4474389.000 instances + 7264791.000 instances Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalHeap": 521412608.000 bytes @@ -227,13 +282,13 @@ different JVMs are already problematic, the performance difference caused by dif modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons. Benchmark Mode Cnt Score Error Units -AllocationBenchmark.run ss 0.113 s/op -AllocationBenchmark.run:+totalAllocatedBytes ss 138762960.000 bytes -AllocationBenchmark.run:+totalAllocatedInstances ss 4474389.000 instances +AllocationBenchmark.run ss 0.166 s/op +AllocationBenchmark.run:+totalAllocatedBytes ss 244216640.000 bytes +AllocationBenchmark.run:+totalAllocatedInstances ss 7264791.000 instances AllocationBenchmark.run:+totalHeap ss 521412608.000 bytes [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ -[INFO] Total time: 8.073 s -[INFO] Finished at: 2024-10-10T12:26:18-04:00 +[INFO] Total time: 8.760 s +[INFO] Finished at: 2024-10-23T12:22:21-04:00 [INFO] ------------------------------------------------------------------------ diff --git a/src/test/java/dev/openfeature/sdk/benchmark/AllocationBenchmark.java b/src/test/java/dev/openfeature/sdk/benchmark/AllocationBenchmark.java index e6f63a98d..cb9422e32 100644 --- a/src/test/java/dev/openfeature/sdk/benchmark/AllocationBenchmark.java +++ b/src/test/java/dev/openfeature/sdk/benchmark/AllocationBenchmark.java @@ -7,6 +7,7 @@ import static dev.openfeature.sdk.testutils.TestFlagsUtils.STRING_FLAG_KEY; import java.util.Map; +import java.util.HashMap; import java.util.Optional; import org.openjdk.jmh.annotations.Benchmark; @@ -41,7 +42,16 @@ public class AllocationBenchmark { public void run() { OpenFeatureAPI.getInstance().setProviderAndWait(new NoOpProvider()); + Map globalAttrs = new HashMap<>(); + globalAttrs.put("global", new Value(1)); + EvaluationContext globalContext = new ImmutableContext(globalAttrs); + OpenFeatureAPI.getInstance().setEvaluationContext(globalContext); + Client client = OpenFeatureAPI.getInstance().getClient(); + + Map clientAttrs = new HashMap<>(); + clientAttrs.put("client", new Value(2)); + client.setEvaluationContext(new ImmutableContext(clientAttrs)); client.addHooks(new Hook() { @Override public Optional before(HookContext ctx, Map hints) { @@ -49,12 +59,16 @@ public Optional before(HookContext ctx, Map invocationAttrs = new HashMap<>(); + invocationAttrs.put("invoke", new Value(3)); + EvaluationContext invocationContext = new ImmutableContext(invocationAttrs); + for (int i = 0; i < ITERATIONS; i++) { client.getBooleanValue(BOOLEAN_FLAG_KEY, false); client.getStringValue(STRING_FLAG_KEY, "default"); client.getIntegerValue(INT_FLAG_KEY, 0); client.getDoubleValue(FLOAT_FLAG_KEY, 0.0); - client.getObjectDetails(OBJECT_FLAG_KEY, new Value(new ImmutableStructure()), new ImmutableContext()); + client.getObjectDetails(OBJECT_FLAG_KEY, new Value(new ImmutableStructure()), invocationContext); } } }