On Mon, 19 Aug 2024 06:39:26 GMT, Shaojin Wen <d...@openjdk.org> wrote:
>> I think you can add a case where the parameters are all these vulnerable >> names like `Ljava/lang/Objecq;` and repeat 8 times, and see how big a >> negative impact these close mismatches have. > > The scenario of `Ljava/lang/Objecq` does not exist. I have added the > following: > > (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; > (Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/Integer; > > > In these two scenarios, the length of `Ljava/lang/String;` is the same as > that of `Ljava/lang/Object;`, and the length of `Ljava/lang/Integer;` is > different from that of `Ljava/lang/Object;`, but the performance is similar. > This proves that the performance overhead of regionMatches is very small. Here are the performance numbers running under Aliyun ECS c8i (my MacBook M1 Pro is not available at this time, so the performance test is run on Alibaba Cloud’s ECS) * CPU Intel®Xeon®Emerald Rapids (Linux x64) ## Benchmark Script # current git checkout ee321904e6eee307f27cb38a70ac4ca75a8f446b make test TEST="micro:java.lang.constant.MethodTypeDescFactories.ofDescriptor" ## Benchmark Numbers Benchmark (descString) Mode Cnt Score Error Units MethodTypeDescFactories.ofDescriptor (Ljava/lang/Object;Ljava/lang/String;)I avgt 6 73.913 ± 0.708 ns/op MethodTypeDescFactories.ofDescriptor ()V avgt 6 1.729 ± 0.013 ns/op MethodTypeDescFactories.ofDescriptor (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; avgt 6 85.204 ± 0.337 ns/op MethodTypeDescFactories.ofDescriptor (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; avgt 6 120.307 ± 1.887 ns/op MethodTypeDescFactories.ofDescriptor (Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/Integer; avgt 6 120.832 ± 1.904 ns/op MethodTypeDescFactories.ofDescriptor ()Ljava/lang/Object; avgt 6 23.709 ± 0.548 ns/op MethodTypeDescFactories.ofDescriptor ([IJLjava/lang/String;Z)Ljava/util/List; avgt 6 109.046 ± 1.712 ns/op MethodTypeDescFactories.ofDescriptor ()[Ljava/lang/String; avgt 6 30.997 ± 0.556 ns/op MethodTypeDescFactories.ofDescriptor (..IIJ)V avgt 6 179.165 ± 2.371 ns/op MethodTypeDescFactories.ofDescriptor ([III.Z[B..[.[B). avgt 6 529.011 ± 12.875 ns/op MethodTypeDescFactories.ofDescriptor (.....................). avgt 6 1690.000 ± 9.597 ns/op This performance number proves my point above that regionMatches has low overhead. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20611#discussion_r1721452746