RFR: 8368633: (fs) Path.toRealPath(NOFOLLOW_LINKS) very slow on macOS

Brian Burkhalter bpb at openjdk.org
Thu Oct 9 19:25:55 UTC 2025


On Thu, 9 Oct 2025 19:04:11 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>>> It's both, I think the only way to avoid the stat call will be to compare the bytes (like the first check).
>> 
>> My thinking was that if `equalsIgnoreCase == false` then the file keys cannot be equal so there is no point checking them. If however `equalsIgnoreCase == true`, then the keys might or might not be equal and need to be checked. So the question is, if `equalsIgnoreCase == false` can the keys be equal?
>
>> My thinking was that if equalsIgnoreCase == false then the file keys cannot be equal so there is no point checking them.
> 
> The encode + decode may may not be a perfect round trip so I don't think this would hold. I think the only safe approach is to compareTo with the byte representation, if they are not equal then need to stat to get the fileKey.

It's not a reason to go forward if the equalsIgnoreCase test is invalid, but dropping this check effectively negates the performance improvement. The path `element` is being compared to all the entries in a DirectoryStream and only one of them will have `compareTo == 0`, so all the rest encountered before the match will need their keys checked.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27709#discussion_r2417752383


More information about the nio-dev mailing list