Skip to content
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

Performance regression introduced with plexus-io 3.4.0 #109

Closed
e-hubert opened this issue Jun 23, 2023 · 8 comments · Fixed by #135
Closed

Performance regression introduced with plexus-io 3.4.0 #109

e-hubert opened this issue Jun 23, 2023 · 8 comments · Fixed by #135
Assignees
Milestone

Comments

@e-hubert
Copy link

e-hubert commented Jun 23, 2023

We faced a notable performance regression of maven builds when updating the maven-jar-plugin which is very likely related to the changes in #79.
What we know for sure is that downgrading the plexus-io dependency from 3.4.0 to 3.3.1 removes the issue.

<dependencies>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-archiver</artifactId>
        <version>3.6.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-io</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- Downgrade plexus-io to 3.3.1 to avoid performance regression during archive build -->
    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-io</artifactId>
        <version>3.3.1</version>
    </dependency>
</dependencies>

This is a captured stacktrace of the slowed down code path:
at sun.nio.fs.UnixNativeDispatcher.getgrgid(java.base@17.0.7/Native Method)
at sun.nio.fs.UnixUserPrincipals.fromGid(java.base@17.0.7/UnixUserPrincipals.java:125)
at sun.nio.fs.UnixFileAttributes.group(java.base@17.0.7/UnixFileAttributes.java:212)
- locked <0x00000006cbf60f10> (a sun.nio.fs.UnixFileAttributes)
at sun.nio.fs.UnixFileAttributeViews$Posix.addRequestedPosixAttributes(java.base@17.0.7/UnixFileAttributeViews.java:237)
at sun.nio.fs.UnixFileAttributeViews$Unix.readAttributes(java.base@17.0.7/UnixFileAttributeViews.java:385)
at sun.nio.fs.AbstractFileSystemProvider.readAttributes(java.base@17.0.7/AbstractFileSystemProvider.java:94)
at java.nio.file.Files.readAttributes(java.base@17.0.7/Files.java:2084)
at org.codehaus.plexus.components.io.attributes.FileAttributes.(FileAttributes.java:110)
at org.codehaus.plexus.components.io.attributes.FileAttributes.(FileAttributes.java:88)
at org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection.addResources(PlexusIoFileResourceCollection.java:163)
at org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection.getResources(PlexusIoFileResourceCollection.java:262)
at org.codehaus.plexus.archiver.AbstractArchiver$1.hasNext(AbstractArchiver.java:564)
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.createArchiveMain(AbstractZipArchiver.java:224)
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.execute(AbstractZipArchiver.java:202)
at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:1028)

We suspect a relation to #79 although we did not look into the details.
Just looking at the stack the cause is likely related to more frequent native FS related calls triggered by execution of java.nio.file.Files.readAttributes from PlexusIoFileResourceCollection.

PS: The used JDK version is not relevant - it at least occurs for both latest OpenJDK 11 and 17 (only tested on Linux, but I'd expect the impact on Windows to be even larger). For a very large project this more than doubled the total build time on some systems - the minimal observed overhead was about 20%, which is still considerable.

@gnodet
Copy link
Member

gnodet commented Jun 24, 2023

See #79 (comment)

@gnodet gnodet self-assigned this Jun 24, 2023
copybara-service bot pushed a commit to google/guava that referenced this issue Jul 8, 2024
…vement was reverted.

(See codehaus-plexus/plexus-io#109.)

This downgrade reduces the time for a clean `mvn source:jar-no-fork -f guava` on our Google workstations from ~53s to ~1s.

(I also upgraded `maven-source-plugin` itself while I was in the area. We still don't have a great way to automatically update Guava _plugins_, only _deps_, as noted offhand in cl/526651811 and discussed slightly more in cl/554548816.)

RELNOTES=n/a
PiperOrigin-RevId: 650382872
copybara-service bot pushed a commit to google/guava that referenced this issue Jul 9, 2024
…vement was reverted.

(See codehaus-plexus/plexus-io#109.)

This downgrade reduces the time for a clean `mvn source:jar-no-fork -f guava` on our Google workstations from ~53s to ~1s.

(I also upgraded `maven-source-plugin` itself while I was in the area. We still don't have a great way to automatically update Guava _plugins_, only _deps_, as noted offhand in cl/526651811 and discussed slightly more in cl/554548816.)

RELNOTES=n/a
PiperOrigin-RevId: 650419894
@cpovirk
Copy link

cpovirk commented Jul 9, 2024

In our case, we found a workaround: The problem appears to happen only with large/remote definitions of Unix groups, so we can avoid it by assigning our files to a group that is part of the local /etc/group file.

@cpovirk
Copy link

cpovirk commented Jul 15, 2024

Oh, and one cool thing I discovered along the way is that ls has a cache of its own for group names: In format_group, it calls getgroup, which implements a cache. Apparently it's been that way for at least 32 years :)

@gnodet
Copy link
Member

gnodet commented Jul 16, 2024

@cpovirk could you please check if #135 fixes the problem for you ?

@gnodet
Copy link
Member

gnodet commented Jul 17, 2024

@cpovirk could you please check if #135 fixes the problem for you ?

and @e-hubert too ...

@marek-neumann-opti
Copy link

Tested the fix from #135 and I can confirm this worked.

@cpovirk
Copy link

cpovirk commented Jul 17, 2024

Confirmed as well. Thanks very much!

@luktom
Copy link

luktom commented Sep 9, 2024

Hi, @gnodet will you bump the plexus-io dependency in related Maven plugins e.g. maven-jar-plugin? Current version of maven-jar-plugin 3.4.2 is affected by performance problem solved in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants