Bug 580568 - jgit slow clone - on java 17+windows - java.io.File.getCanonicalPath ()
Summary: jgit slow clone - on java 17+windows - java.io.File.getCanonicalPath ()
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 6.3   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 6.4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-15 02:40 EDT by Jörg Kubitz CLA
Modified: 2022-09-22 05:19 EDT (History)
1 user (show)

See Also:


Attachments
Screenshot sampling.png (143.84 KB, image/png)
2022-08-15 02:40 EDT, Jörg Kubitz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg Kubitz CLA 2022-08-15 02:40:58 EDT
Created attachment 288681 [details]
Screenshot sampling.png

With using java 17 on Windows more then half of the time cloning is spend in java.io.File.getCanonicalPath () called from constructor org.eclipse.jgit.internal.storage.file.ObjectDirectory.AlternateHandle.Id.Id(File).

That is because getCanonicalPath does not cache the result anymore.

Please avoid using getCanonicalPath(): I am sure git does not want to let the OS compute the actual capitalization of all directories in the files path nor follow links.

May be the cheap File:getAbsolutePath() is enough?

Or if you really need to rely on the OS here then java.nio.file.Files.getFileAttributeView(Path, Class<V>, LinkOption...) + java.nio.file.attribute.BasicFileAttributes.fileKey() could be used instead - since the name is used for comparison only anyway.
Comment 1 Eclipse Genie CLA 2022-08-15 05:05:27 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/195186
Comment 2 Matthias Sohn CLA 2022-09-22 04:51:27 EDT
JDK 12 issue tracking removal of canonicalization cache:
https://bugs.openjdk.java.net/browse/JDK-8207005