6870926: (file) Path.toRealPath performance can be improved (win)

Alan Bateman Alan.Bateman at Sun.COM
Thu Aug 13 08:48:28 PDT 2009


Sherman,

Do you mind reviewing this one? It's a rejig of the toRealPath 
implementation on Windows to make it faster for common cases. The two 
main changes are:

1. On Vista/2008 there is a possibility of sym links in the path so the 
implementation has been using GetFinalPathNameByHandle to get the final 
path. This is a lot more expensive than originally expected, with the 
result that toRealPath(true) is a lot slower than toRealPath(false) when 
they should take around the same time for the common case that there 
aren't any sym links in the path. The change is to assume that the path 
does not contain any symbolic links and if a reparse point is 
encountered during the iteration only then attempt to get the final path 
with GetFinalPathNameByHandle.

2. The other performance issue, for XP/2003 and toRealPath(false) at 
least, is that the implementation always checks that the root directory 
exists. This check is expensive and can be safety skipped when the path 
has one or more name elements. Related to this, is that when the path 
consistent solely of a root directory then the fastest way to verify its 
existence is to use GetFileAttributes.

http://cr.openjdk.java.net/~alanb/6870926/webrev.00/

Thanks,

Alan.



More information about the nio-dev mailing list