RFR: 8314569: (fs) Improve normalization of UnixPath for input with trailing slashes [v2]

Sergey Tsypanov stsypanov at openjdk.org
Tue Aug 29 07:56:14 UTC 2023


On Tue, 29 Aug 2023 07:40:21 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Updated the PR. Checked cases for normal path (requires no normalization) and root:
>> 
>> @BenchmarkMode(Mode.AverageTime)
>> @OutputTimeUnit(TimeUnit.NANOSECONDS)
>> @Warmup(time = 2, iterations = 5)
>> @Measurement(time = 2, iterations = 5)
>> @Fork(value = 4, jvmArgs = "-Xmx1g")
>> public class FileToPathBenchmark {
>> 
>>     @Benchmark
>>     public Path toDirectoryPath(Data data) {
>>         return FileSystems.getDefault().getPath(data.directoryPath);
>>     }
>> 
>> 
>>     @Benchmark
>>     public Path toDirectoryPathDoubleSlash(Data data) {
>>         return FileSystems.getDefault().getPath(data.directoryPathWithDoubleSlash);
>>     }
>> 
>>     @Benchmark
>>     public Path toNormalPath(Data data) {
>>         return FileSystems.getDefault().getPath(data.normalPath);
>>     }
>> 
>>     @Benchmark
>>     public Path toRootPath(Data data) {
>>         return FileSystems.getDefault().getPath(data.rootPath);
>>     }
>> 
>>     @State(Scope.Thread)
>>     public static class Data {
>>         private final String rootPath = "/";
>>         private final String normalPath = "/tmp/tmp/tmp";
>>         private final String directoryPath = "/tmp/tmp/tmp/";
>>         private final String directoryPathWithDoubleSlash = "/tmp//tmp/tmp/";
>>     }
>> }
>> 
>> Results:
>> 
>> baseline
>> 
>> Benchmark                                                           Mode  Cnt     Score     Error   Units
>> FileToPathBenchmark.toDirectoryPath                                 avgt   20    44.993 ±   1.676   ns/op
>> FileToPathBenchmark.toDirectoryPath:·gc.alloc.rate                  avgt   20  3732.628 ± 137.446  MB/sec
>> FileToPathBenchmark.toDirectoryPath:·gc.alloc.rate.norm             avgt   20   176.000 ±   0.001    B/op
>> FileToPathBenchmark.toDirectoryPath:·gc.count                       avgt   20   234.000            counts
>> FileToPathBenchmark.toDirectoryPath:·gc.time                        avgt   20  1129.000                ms
>> FileToPathBenchmark.toDirectoryPathDoubleSlash                      avgt   20    58.963 ±   1.737   ns/op
>> FileToPathBenchmark.toDirectoryPathDoubleSlash:·gc.alloc.rate       avgt   20  2717.169 ±  78.664  MB/sec
>> FileToPathBenchmark.toDirectoryPathDoubleSlash:·gc.alloc.rate.norm  avgt   20   168.000 ±   0.001    B/op
>> FileToPathBenchmark.toDirectoryPathDoubleSlash:·gc.count            avgt   20   190.000            counts
>> FileToPathBenchmark.toDirectoryPathDoubleSlash:·gc.time             avgt   20   755.000                ms
>> FileToPathBenchmark.toNormalPath       ...
>
> @stsypanov The title on the PR is currently:
> 
> "(fs) Improve normalization of UnixPath for directories(fs) Improve normalization of UnixPath for input with trailing slashes #15342"
> 
> Something got fat fingered somewhere. Can you fix it to match the JBS issue  "(fs) Improve normalization of UnixPath for input with trailing slashes" and then we can sponsor?

@AlanBateman done

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

PR Comment: https://git.openjdk.org/jdk/pull/15342#issuecomment-1696948242


More information about the nio-dev mailing list