RFR: 8353013: java.net.URI.create(String) may have low performance to scan the host/domain name from URI string when the hostname starts with number [v3]

Andrey Turbanov aturbanov at openjdk.org
Wed Apr 16 13:05:44 UTC 2025


On Mon, 14 Apr 2025 16:34:33 GMT, Rohitash Kumar <duke at openjdk.org> wrote:

>> test/jdk/java/net/URI/Test.java line 1791:
>> 
>>> 1789: 
>>> 1790:     // 8353013 - java.net.URI.create(String) may have low performance to scan the host/domain name from
>>> 1791:     //           URI string when the hostname starts with number
>> 
>> This comment looks a bit out of place in a unit test. I think start with a JMH benchmark and change the comment in the unit test to make it clearer that it's providing more test coverage for cases where the authority component of a hierarchical URI has a host component that starts with a number.
>
> Thanks! I have updated the comment and added a JMH benchmark.
> 
> 
> ## Before
> Benchmark                                                      (uri)  Mode  Cnt     Score    Error  Units
> URIAuthorityParsingBenchmark.create  https://98765432101.abc.xyz.com  avgt   15  1495.273 ± 86.157  ns/op
> URIAuthorityParsingBenchmark.create  https://ABCDEFGHIJK.abc.xyz.com  avgt   15   363.048 ±  6.510  ns/op
> 
> ## After
> Benchmark                                                    Mode  Cnt    Score    Error  Units
> Benchmark                                                      (uri)  Mode  Cnt    Score    Error  Units
> URIAuthorityParsingBenchmark.create  https://98765432101.abc.xyz.com  avgt   15  377.741 ± 10.497  ns/op
> URIAuthorityParsingBenchmark.create  https://ABCDEFGHIJK.abc.xyz.com  avgt   15  334.215 ±  2.148  ns/op

Isn't is suspicious that non-number case got speedup too?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24295#discussion_r2046885870


More information about the net-dev mailing list