Skip to content

Investigate mvn4 large graph performance regression #2481

Open
@mbien

Description

@mbien

Affected version

4.0.0-rc-3 (resolver 2.0.9)

Bug description

I use this issue to investigate the performance regression posted on the dev list. Github allows to embed pictures which makes sharing flame graphs easier compared to mail.

benchmark project taken from mail thread (thanks to @seregamorph for coming up with a reproducer!):
https://github.com/maven-turbo-reactor/maven-multiproject-generator (https://www.mail-archive.com/[email protected]/msg135612.html)

setup (first line are kernel settings for async-profiler):

sudo sysctl kernel.kptr_restrict=0 && sudo sysctl kernel.perf_event_paranoid=1
export JAVA_HOME=/home/mbien/dev/java/jdk-24.0.1.9.1-corretto

mvn3 run:

export MAVEN_OPTS=-agentpath:/home/mbien/dev/java/async-profiler-4.0-linux-x64/lib/libasyncProfiler.so=start,event=cpu,file=maven3.html
/home/mbien/dev/java/apache-maven-9.9.10_40/bin/mvn clean install

mvn4 run:

export MAVEN_OPTS=-agentpath:/home/mbien/dev/java/async-profiler-4.0-linux-x64/lib/libasyncProfiler.so=start,event=cpu,file=maven4.html
/home/mbien/dev/java/apache-maven-4.0.0-rc-3/bin/mvn clean install

(i ran a warmup run first before measuring)

m3
Total time:  01:03 min (Wall Clock)

m4
Total time:  03:08 min (Wall Clock)

(old intel i7 on NVME)

first observation:

mvn3 has 3 paths leading into DefaultRepositorySystem.collectDependencies, mvn4 has 4. The extra path comes from DefaultConsumerPomBuilder, see second observation.

Graphs show relative execution time. No totals.

note: one path is very fast and not visible on this zoom level in both cases, purple marks collectDependencies

mvn3:
Image

mvn4:
Image

second observation:

The reason for that seems to be the install stage. More time is spent in InstallMojo:

m3:

Image

m4:

Image

zooming in shows the difference, the whole RepositoryUtils.toArtifact path is new and is the cause for the extraDefaultRepositorySystem.collectDependencies call.

m3:

Image

m4:

Image

third observation:

more time is spent computing hash codes, purple highlights methods containing "hash".

mvn3:
Image

mvn4:
Image

lets zoom into a single collectDependencies call

mvn3:
Image

mvn4:
Image

full flame graphs as html (compressed since github doesn't like html):

maven3.html.gz
maven4rc3.html.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions