native-platform icon indicating copy to clipboard operation
native-platform copied to clipboard

Improve stat performance on Windows

Open wolfs opened this issue 4 years ago • 0 comments

The PR https://github.com/gradle/native-platform/pull/37 switched from using GetFileAttributesExW to GetFileInformationByHandle for symlink support. This seems to be much slower.

The same issue seems to have appeared in Visual Studio: https://github.com/Microsoft/msbuild/issues/2052

There, they fixed this in https://github.com/microsoft/msbuild/pull/2087 by first calling GetFileAttributesExW, and then falling back to use GetFileInformationByHandle only if the target is actually a symlink.

The JMH benchmark in the native subproject of gradle/gradle shows the difference:

Latest native platform, Windows 10 (from https://github.com/gradle/gradle/pull/12966#issuecomment-621957148): image

Old benchmark result from 2017 (from https://github.com/gradle/gradle/pull/1183#issuecomment-273461134):

image

Java NIO seems to be using GetFileAttributesW, and I think that is the only explanation for the much higher performance.

wolfs avatar May 04 '20 17:05 wolfs