Skip to content

Commit 52cbab0

Browse files
committed
fixup: mutabilit
Signed-off-by: Todd Baert <[email protected]>
1 parent 7a98827 commit 52cbab0

File tree

2 files changed

+57
-57
lines changed

2 files changed

+57
-57
lines changed

benchmark.txt

+55-55
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Audit done.
3333
processing is enabled explicitly (-proc:only, -proc:full).
3434
Use -Xlint:-options to suppress this message.
3535
Use -proc:none to disable annotation processing.
36-
[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.
37-
[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.
3836
[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.
37+
[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.
38+
[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.
3939
[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
4040
[INFO] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/NoOpProvider.java: Some input files use or override a deprecated API.
4141
[INFO] /home/todd/git/java-sdk/src/main/java/dev/openfeature/sdk/NoOpProvider.java: Recompile with -Xlint:deprecation for details.
@@ -70,57 +70,57 @@ Audit done.
7070

7171
# Run progress: 0.00% complete, ETA 00:00:00
7272
# Fork: 1 of 1
73-
[0.002s][warning][gc,init] Consider setting -Xms equal to -Xmx to avoid resizing hiccups
74-
[0.002s][warning][gc,init] Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups
73+
[0.001s][warning][gc,init] Consider setting -Xms equal to -Xmx to avoid resizing hiccups
74+
[0.001s][warning][gc,init] Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups
7575
Iteration 1: num #instances #bytes class name (module)
7676
-------------------------------------------------------
77-
1: 732138 35142624 java.util.HashMap ([email protected])
77+
1: 1140090 54724320 java.util.HashMap ([email protected])
7878
2: 250067 14003752 java.util.stream.ReferencePipeline$Head ([email protected])
79-
3: 47792 9311464 [B ([email protected])
80-
4: 300056 4800896 java.util.HashMap$EntrySet ([email protected])
81-
5: 150000 4800000 java.util.ArrayList$ArrayListSpliterator ([email protected])
82-
6: 105996 4506240 [Ljava.lang.Object; ([email protected])
83-
7: 280124 4481984 dev.openfeature.sdk.ImmutableStructure
84-
8: 270124 4321984 dev.openfeature.sdk.ImmutableContext
79+
3: 700056 11200896 java.util.HashMap$EntrySet ([email protected])
80+
4: 47801 9303280 [B ([email protected])
81+
5: 486170 7778720 dev.openfeature.sdk.ImmutableStructure
82+
6: 476170 7618720 dev.openfeature.sdk.ImmutableContext
83+
7: 150000 4800000 java.util.ArrayList$ArrayListSpliterator ([email protected])
84+
8: 105995 4506088 [Ljava.lang.Object; ([email protected])
8585
9: 100000 4000000 dev.openfeature.sdk.HookContext
8686
10: 100000 4000000 dev.openfeature.sdk.HookContext$HookContextBuilder
87-
11: 120706 2896944 java.util.ArrayList ([email protected])
87+
11: 126752 3042048 java.util.ArrayList ([email protected])
8888
12: 50000 2800000 java.util.stream.ReferencePipeline$7 ([email protected])
89-
13: 50000 2400000 dev.openfeature.sdk.FlagEvaluationDetails$FlagEvaluationDetailsBuilder
90-
14: 152 2227424 [Ljdk.internal.vm.FillerElement; ([email protected])
91-
15: 135755 2172080 dev.openfeature.sdk.internal.AutoCloseableReentrantReadWriteLock$$Lambda/0x000070c57402eae8
92-
16: 66533 2129056 java.util.ArrayList$Itr ([email protected])
93-
17: 50062 2002480 java.util.Spliterators$ArraySpliterator ([email protected])
94-
18: 50000 2000000 dev.openfeature.sdk.FlagEvaluationDetails
95-
19: 50000 2000000 dev.openfeature.sdk.ProviderEvaluation
96-
20: 50000 2000000 dev.openfeature.sdk.ProviderEvaluation$ProviderEvaluationBuilder
97-
21: 50060 1601920 java.util.stream.Collectors$CollectorImpl ([email protected])
98-
22: 50060 1601920 java.util.stream.ReduceOps$3ReducingSink ([email protected])
99-
23: 50002 1600064 java.util.Collections$UnmodifiableMap ([email protected])
100-
24: 100001 1600016 dev.openfeature.sdk.NoOpProvider$$Lambda/0x000070c57402fa78
101-
25: 50000 1600000 [Ljava.util.List; ([email protected])
102-
26: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata
103-
27: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata$ImmutableMetadataBuilder
104-
28: 100000 1600000 dev.openfeature.sdk.OpenFeatureClient$$Lambda/0x000070c5740826c0
105-
29: 50000 1200000 dev.openfeature.sdk.FlagEvaluationOptions
106-
30: 50000 1200000 dev.openfeature.sdk.FlagEvaluationOptions$FlagEvaluationOptionsBuilder
107-
31: 50000 1200000 dev.openfeature.sdk.HookSupport$$Lambda/0x000070c574081500
108-
32: 50000 1200000 dev.openfeature.sdk.HookSupport$$Lambda/0x000070c574081730
109-
33: 50000 1200000 java.util.stream.ReferencePipeline$7$1 ([email protected])
110-
34: 70131 1122096 java.util.Optional ([email protected])
111-
35: 33185 1061920 java.util.stream.ReduceOps$3 ([email protected])
112-
36: 4491 679416 [I ([email protected])
113-
37: 26575 637800 java.lang.String ([email protected])
114-
38: 1462 390280 [J ([email protected])
115-
39: 11653 372896 java.util.HashMap$EntryIterator ([email protected])
116-
40: 2356 288240 java.lang.Class ([email protected])
89+
13: 50062 2002480 java.util.Spliterators$ArraySpliterator ([email protected])
90+
14: 50000 2000000 dev.openfeature.sdk.FlagEvaluationDetails
91+
15: 50000 2000000 dev.openfeature.sdk.ProviderEvaluation
92+
16: 160 1799192 [Ljdk.internal.vm.FillerElement; ([email protected])
93+
17: 51775 1656800 java.util.ArrayList$Itr ([email protected])
94+
18: 50060 1601920 java.util.stream.Collectors$CollectorImpl ([email protected])
95+
19: 50060 1601920 java.util.stream.ReduceOps$3ReducingSink ([email protected])
96+
20: 50002 1600064 java.util.Collections$UnmodifiableMap ([email protected])
97+
21: 100001 1600016 dev.openfeature.sdk.NoOpProvider$$Lambda/0x00007c562402fa78
98+
22: 50000 1600000 [Ljava.util.List; ([email protected])
99+
23: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata
100+
24: 100000 1600000 dev.openfeature.sdk.OpenFeatureClient$$Lambda/0x00007c5624082430
101+
25: 99350 1589600 dev.openfeature.sdk.ImmutableMetadata$ImmutableMetadataBuilder
102+
26: 50000 1200000 dev.openfeature.sdk.FlagEvaluationOptions
103+
27: 50000 1200000 java.util.stream.ReferencePipeline$7$1 ([email protected])
104+
28: 71122 1137952 java.util.Optional ([email protected])
105+
29: 18775 901200 dev.openfeature.sdk.FlagEvaluationDetails$FlagEvaluationDetailsBuilder
106+
30: 22140 885600 dev.openfeature.sdk.ProviderEvaluation$ProviderEvaluationBuilder
107+
31: 34680 832320 dev.openfeature.sdk.FlagEvaluationOptions$FlagEvaluationOptionsBuilder
108+
32: 4491 679416 [I ([email protected])
109+
33: 26582 637968 java.lang.String ([email protected])
110+
34: 38046 608736 dev.openfeature.sdk.internal.AutoCloseableReentrantReadWriteLock$$Lambda/0x00007c562402eae8
111+
35: 24049 577176 dev.openfeature.sdk.HookSupport$$Lambda/0x00007c5624081478
112+
36: 21192 508608 dev.openfeature.sdk.HookSupport$$Lambda/0x00007c5624081248
113+
37: 1462 390280 [J ([email protected])
114+
38: 11678 373696 java.util.stream.ReduceOps$3 ([email protected])
115+
39: 2356 288208 java.lang.Class ([email protected])
116+
40: 8513 272416 java.util.HashMap$EntryIterator ([email protected])
117117
41: 4631 259336 jdk.internal.org.objectweb.asm.SymbolTable$Entry ([email protected])
118118
42: 10001 240024 java.lang.Double ([email protected])
119119
43: 2502 180144 java.lang.reflect.Field ([email protected])
120120
44: 10000 160000 dev.openfeature.sdk.Value
121-
45: 6008 144192 java.lang.StringBuilder ([email protected])
121+
45: 6009 144216 java.lang.StringBuilder ([email protected])
122122
46: 180 140968 [Ljdk.internal.org.objectweb.asm.SymbolTable$Entry; ([email protected])
123-
47: 3829 122528 java.util.concurrent.ConcurrentHashMap$Node ([email protected])
123+
47: 3827 122464 java.util.concurrent.ConcurrentHashMap$Node ([email protected])
124124
48: 48 122168 [C ([email protected])
125125
49: 1441 113592 [S ([email protected])
126126
50: 1201 105688 java.lang.reflect.Method ([email protected])
@@ -129,13 +129,13 @@ Iteration 1: num #instances #bytes class name (module)
129129
53: 1561 74928 java.lang.invoke.MemberName ([email protected])
130130
54: 334 74816 jdk.internal.org.objectweb.asm.MethodWriter ([email protected])
131131
55: 1799 71960 java.lang.invoke.MethodType ([email protected])
132-
56: 1088 69632 java.net.URL ([email protected])
132+
56: 1089 69696 java.net.URL ([email protected])
133133
57: 2011 64352 java.util.HashMap$Node ([email protected])
134134
58: 121 50512 [Ljava.util.concurrent.ConcurrentHashMap$Node; ([email protected])
135135
59: 3149 50384 jdk.internal.util.StrongReferenceKey ([email protected])
136136
60: 491 49608 [Ljava.util.HashMap$Node; ([email protected])
137137
61: 1057 42280 java.io.ObjectStreamField ([email protected])
138-
62: 1224 39168 java.io.File ([email protected])
138+
62: 1225 39200 java.io.File ([email protected])
139139
63: 779 37392 jdk.internal.org.objectweb.asm.Frame ([email protected])
140140
64: 243 25272 java.util.jar.JarFile$JarFileEntry ([email protected])
141141
65: 794 25248 [Ljava.lang.String; ([email protected])
@@ -193,20 +193,20 @@ Iteration 1: num #instances #bytes class name (module)
193193
117: 234 5616 java.util.jar.Attributes$Name ([email protected])
194194
118: 174 5568 java.util.concurrent.locks.ReentrantLock$NonfairSync ([email protected])
195195
truncated...
196-
Total 4045727 138758864
196+
Total 5005903 163928784
197197

198-
0.157 s/op
199-
+totalAllocatedBytes: 138758864.000 bytes
200-
+totalAllocatedInstances: 4045727.000 instances
198+
0.116 s/op
199+
+totalAllocatedBytes: 163928784.000 bytes
200+
+totalAllocatedInstances: 5005903.000 instances
201201
+totalHeap: 521412608.000 bytes
202202

203203

204204

205205
Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalAllocatedBytes":
206-
138758864.000 bytes
206+
163928784.000 bytes
207207

208208
Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalAllocatedInstances":
209-
4045727.000 instances
209+
5005903.000 instances
210210

211211
Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalHeap":
212212
521412608.000 bytes
@@ -227,13 +227,13 @@ different JVMs are already problematic, the performance difference caused by dif
227227
modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons.
228228

229229
Benchmark Mode Cnt Score Error Units
230-
AllocationBenchmark.run ss 0.157 s/op
231-
AllocationBenchmark.run:+totalAllocatedBytes ss 138758864.000 bytes
232-
AllocationBenchmark.run:+totalAllocatedInstances ss 4045727.000 instances
230+
AllocationBenchmark.run ss 0.116 s/op
231+
AllocationBenchmark.run:+totalAllocatedBytes ss 163928784.000 bytes
232+
AllocationBenchmark.run:+totalAllocatedInstances ss 5005903.000 instances
233233
AllocationBenchmark.run:+totalHeap ss 521412608.000 bytes
234234
[INFO] ------------------------------------------------------------------------
235235
[INFO] BUILD SUCCESS
236236
[INFO] ------------------------------------------------------------------------
237-
[INFO] Total time: 5.275 s
238-
[INFO] Finished at: 2024-10-10T09:59:32-04:00
237+
[INFO] Total time: 6.487 s
238+
[INFO] Finished at: 2024-10-10T11:03:16-04:00
239239
[INFO] ------------------------------------------------------------------------

src/main/java/dev/openfeature/sdk/ImmutableContext.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public String getTargetingKey() {
7979
@Override
8080
public EvaluationContext merge(EvaluationContext overridingContext) {
8181
if (overridingContext == null || overridingContext.isEmpty()) {
82-
return this;
82+
return new ImmutableContext(this.asMap());
8383
}
8484
if (this.isEmpty()) {
85-
return overridingContext;
85+
return new ImmutableContext(overridingContext.asMap());
8686
}
8787

8888
return new ImmutableContext(

0 commit comments

Comments
 (0)