[ 
https://issues.apache.org/jira/browse/MRESOLVER-68?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17172644#comment-17172644
 ] 

Michael Osipov edited comment on MRESOLVER-68 at 8/9/20, 3:01 PM:
------------------------------------------------------------------

I think that this ticket is not required because no the canonicalization 
necessary. The {{TrackingFileManager}} is package private, thus never used 
externally. It uses the interned string reperesentation of the canonical path 
and file locking. We all know that file locking in a single JVM are pointless, 
it will lead to race conditions. This is why the locking is multistage. Single 
JVM and file locks for multi JVM. The interesting part is that if you look up 
the call stack of  {{TrackingFileManager#read(File)}} and 
{{TrackingFileManager#update(File, Map<String, String>)}} you'll see that all 
of them are wrapped in a {{SyncContext}} which already add locks for them. I 
don't understand why this is done here. If outer lock works, I see no need to 
lock again somewhere deeper. I am also keen to say that this kind of 
synchronization can be completely removed if you have a decent 
{{SyncContextFactory}} implementation.
 I am inclined to override the {{TrackingFileManager}} with MRESOLVER-130 for 
obvious reasons.
[~elharo], please add your thoughts on my analysis.


was (Author: michael-o):
I think that this ticket is not required not is the canonicalization necessary. 
The {{TrackingFileManager}} is package private, thus never used externally. It 
used the interned string reperesentation of the canonical path and file 
locking. We all know that file locking in a single JVM are pointless, it will 
lead to race conditions. This is why the locking is multistage. Single JVM and 
file locks for multi JVM. The interesting part is that if you look up the call 
stack of  {{TrackingFileManager#read(File)}} and 
{{TrackingFileManager#update(File, Map<String, String>)}} you'll see that all 
of them are wrapped in a {{SyncContext}} which already add locks for them. I 
don't understand why this is done here. If outer look works, I see no need to 
lock again somewhere deeper. I am also keen to say that this kind of 
synchronization can be completely removed if you have a decent 
{{SyncContextFactory}} implementation.
 I am inclined to override the {{TrackingFileManager}} with MRESOLVER-130 for 
obvious reasons.
[~elharo], please add your thoughts on my analysis.

> Add caching around File.getCanonicalPath
> ----------------------------------------
>
>                 Key: MRESOLVER-68
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-68
>             Project: Maven Resolver
>          Issue Type: Improvement
>          Components: resolver
>            Reporter: Richard Atkins
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Maven Resolver spends a lot of time calculating the canonical path for a 
> File, and subsequently interning the result, in order to generate an in 
> memory lock object for the File. This can add up to 50% or more of the time 
> in a build, especially when using maven-enforcer-plugin with the 
> bannedDependencies rule with searchTransitive true.
> Caching these lookups will reduce build times, even for well behaved plugins.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to