-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore speed improvements #79
Restore speed improvements #79
Conversation
src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java
Show resolved
Hide resolved
src/main/java/org/codehaus/plexus/components/io/attributes/PlexusIoResourceAttributeUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResourceCollection.java
Show resolved
Hide resolved
@plamentotev would you mind having a quick look ? |
I'll try to check it later this week or the beginning of the next. But I'm not completely sure what caused the original issue. And I wonder if there is simpler solution that keeping tract of the target using nested resource. |
@@ -21,7 +21,7 @@ public void testRealSymlink() | |||
final File file = new File( "src/test/resources/symlinks/src/symDir" ); | |||
PlexusIoResourceAttributes attrs = FileAttributes.uncached( file ); | |||
assertTrue( attrs.isSymbolicLink() ); | |||
PlexusIoFileResource r = new PlexusIoFileResource( file, "symDir", attrs ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my understanding is correct this change does not keep the current behavior of PlexusIoFileResource
. If this is the case it should be a separate change (possibly requiring major version update if it is breaking change) as it is not just performance improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. The PlexusIoFileResource
has no public constructor, so the only way it can be created is through ResourceFactory.createResource
or other internal methods.
What happens is that I think this change restores the original idea : PlexusIoSymlinkResource
instances are used to represent symlinks and PlexusIoFileResource
for regular files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the initial commit, is that I missed the fact that attributes are handled in a very specific (and not necessarily intuitive way) for links : some attributes are retrieved from the link and some others from the target.
That's the reason why I've introduced the getLink()
and getTarget()
methods on the PlexusIoSymlinkResource
which return PlexusIoResource
instances that will more explicitly handle the link and the target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. Now it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if you can add some comments as for why getLink and getTarget are there to make it more clearer.
src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResource.java
Outdated
Show resolved
Hide resolved
src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java
Outdated
Show resolved
Hide resolved
src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java
Outdated
Show resolved
Hide resolved
src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java
Show resolved
Hide resolved
/** | ||
* @deprecated use {@link #FileAttributes(File)} and remove the unused userCache and groupCache parameters | ||
*/ | ||
@Deprecated | ||
public FileAttributes( @Nonnull File file, @Nonnull Map<Integer, String> userCache, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InlineMeSuggester: This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
public FileAttributes( @Nonnull File file, @Nonnull Map<Integer, String> userCache, | |
@InlineMe(replacement = "this(file)") |
(at-me in a reply with help
or ignore
)
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
This reverts commit bf86860.
The PlexusIoFileResource constructor calls file.lastModified(), file.length(), file.isFile(), file.isDirectory() and file.exists() which is very inefficient
139a7e7
to
46245e4
Compare
I've pushed another commit which removes another set of file attributes access. We should be down to 2 calls per file, one with the follow links options and one without. |
|
||
public class PlexusIoSymlinkResource | ||
extends PlexusIoFileResource | ||
implements SymlinkDestinationSupplier | ||
{ | ||
private final File symnlinkDestination; | ||
private final String symLinkDestination; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnusedVariable: The field 'symLinkDestination' is never read.
(at-me in a reply with help
or ignore
)
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
@@ -39,6 +40,10 @@ | |||
public class FileAttributes | |||
implements PlexusIoResourceAttributes | |||
{ | |||
public static final LinkOption[] FOLLOW_LINK_OPTIONS = new LinkOption[] { }; | |||
|
|||
public static final LinkOption[] NOFOLLOW_LINK_OPTIONS = new LinkOption[] { LinkOption.NOFOLLOW_LINKS }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MutablePublicArray: Non-empty arrays are mutable, so this public static final
array is not a constant and can be modified by clients of this class. Prefer an ImmutableList, or provide an accessor method that returns a defensive copy.
(at-me in a reply with help
or ignore
)
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
Just a note: would be good if this PR goes in BEFORE this one #84 as it will most probably conflict (let me handle it) and it also removes Plexus completely, hence no more Junit3 tests as well... |
src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResource.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Squash, merge and move on.
I suspect this has caused https://issues.apache.org/jira/projects/MASSEMBLY/issues/MASSEMBLY-965. See also #89. |
for ( String name : resources ) | ||
{ | ||
String sourceDir = name.replace( '\\', '/' ); | ||
File f = new File( dir, sourceDir ); | ||
|
||
PlexusIoResourceAttributes attrs = new FileAttributes( f, cache1, cache2 ); | ||
attrs = mergeAttributes( attrs, f.isDirectory() ); | ||
FileAttributes fattrs = new FileAttributes( f ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This usage without the caches is now quite expensive and likely causing a performance regression reported in #109
No description provided.