Howdy,

Yes, it was "by design" at start, as the local repository was assumed
to be shared across multiple Maven versions (3.6, 3.8, 3.9 that got
opt-in RRF and 3.10 that has it as opt-out).

Your PR is good, and I will accept it, but it has one important side
effect that needs to be mentioned:
it should be consistently used with the same (3.10.x) version.

Thanks
T


On Tue, 1 Dec 2026 at 12:09, Alexander Bubenchikov via dev
<[email protected]> wrote:
>
> Hi all,
>
> I work on the Maven integration in IntelliJ IDEA. I was profiling the
> import of a large project and the
> remote repository filter stood out: it's behind about a quarter of all
> allocation in dependency resolution,
> plus 5–8 % of CPU and wall time. The cost comes from the order of
> steps in DefaultArtifactResolver. Fixing
> it would be observable and potentially could change behaviour, so
> before I send a PR I'd like to know if the order is deliberate.
>
> ## What happens today
>
> For each ArtifactRequest, DefaultArtifactResolver.resolve():
>
> 1. calls RemoteRepositoryFilter.acceptArtifact() for every remote
> repository on the request, and adds an
>    ArtifactFilteredOutException to the ArtifactResult for each one it rejects;
> 2. resolves the version against the accepted repositories;
> 3. checks the workspace reader;
> 4. looks up the local repository with only the accepted repositories;
> 5. downloads if nothing usable is on disk.
>
> Resolver 2.x turns on the "prefixes" and "groupId" sources by default,
> so step 1 runs in every default
> build. In a big build nearly every request is a local hit. That means
> one filter call per remote
> repository for an artifact that's already on disk.
>
> Two side effects look accidental to me, but I may be wrong:
>
> - A locally resolved artifact still gets an
> ArtifactFilteredOutException for each rejected repository,
>   even though nothing was contacted.
> - A workspace hit (step 3) pays for step 1 too, and gets the same exceptions.
>
> ## Questions
>
> Is this order by design, or did it just fall out of where the filter
> was hooked in?
>
> 1. Does Maven, a plugin, or any tool you know of read the
> ArtifactFilteredOutException entries of an
>    artifact that resolved from the local repository or the workspace?
> (Intellij IDEA does not)
> 2. I'm guessing one part of the order is intentional: a local copy
> cached from a repository the filter now
>    rejects must not be used. Is that right? My change keeps it.
> 3. resolve() calls VersionResolver.resolveVersion() for every request,
> plain releases like 1.2.3 included.
>    Maven's VersionResolver (maven-resolver-provider) returns those
> unchanged and reads no metadata, so my
>    change skips the call when a release resolves from the workspace or
> the local repository. But
>    VersionResolver is pluggable. Do you know of an implementation that
> rewrites release versions or relies
>    on this call?  (Intellij IDEA does not). If it has to stay, I'll
> keep it. I haven't measured that variant yet.
>
> ## What I tried
>
> Only release versions are touched. Snapshots, RELEASE and LATEST keep
> today's order, because their version
> resolution reads metadata from the accepted repositories. For releases:
>
> - Steps 3 and 4 move ahead of step 1, and that early local lookup uses
> all repositories on the request.
>   A workspace hit or a local hit no longer records any
> ArtifactFilteredOutException.
> - Step 1 drops to a single call: is the repository the local copy came
> from enabled and accepted?
>   A locally installed artifact has no such repository, so it gets no
> filter call at all.
> - Step 2 doesn't run when the artifact resolves from the workspace or
> the local repository.
> - If the filter rejects the local copy's repository, steps 1–5 run as
> they do today. On a local miss they
>   run too, but step 4 reuses the miss: fewer repositories can't find more.
>
> As far as I can tell, the resolved file and the repository in
> ArtifactResult don't change.
>
> On tests:  One test
> fails.DefaultArtifactResolverTest.testResolveRemoteArtifactSkipsFilterForDisabledRepositoryPolicy
> asserted that the local lookup gets the filtered repositories. The
> lookup now runs first, so I dropped that
> assertion. The test still checks what it's really about (no
> ArtifactFilteredOutException for a repository
> with a disabled policy), and it now also checks that a local miss
> costs one lookup, as before.
>
> ## Numbers
>
> - Maven 3.10.2 with Resolver master 3bfffc10, with and without the
> change. Only the Resolver jars differ.
> - A synthetic project: 1667 modules, ~475 declared dependencies each.
> settings.xml declares 10 remote
>   repositories, and the dependency POMs add more.
> - A core extension runs ProjectDependenciesResolver.resolve(new
> DefaultDependencyResolutionRequest(project,
>   session)) for every reactor project on 12 threads. No plugins run
> and nothing compiles. It reports wall
>   time, plus CPU time and allocated bytes of the 12 threads
> (ThreadMXBean). "Young GC" is what young and
>   mixed collections reclaimed, from -Xlog:gc.
> - 2,535,614 artifact resolutions per run. The local repository holds
> 1,516 jars and 4,771 POMs (1.1 GB).
> - Warm runs start from a copy of the same filled local repository.
> Clean runs start empty, so their wall
>   time includes downloading 1.1 GB.
> - Median of 3 interleaved runs on an Apple M-series laptop. Brackets
> show the difference vs. master.
> - The "+ #2379" rows also include
> https://github.com/apache/maven-resolver/pull/2379. It's an open PR
> that
>   removes per-call allocation in DefaultRemoteRepositoryFilterManager
> and doesn't change behaviour.
>
> Warm local repository (master / change / change + #2379):
> - allocated: 403.7 GB / 299.0 GB (-25.9%) / 296.4 GB (-26.6%)
> - young GC: 425.8 GB / 319.7 GB (-24.9%) / 317.8 GB (-25.4%)
> - CPU: 864 s / 799 s (-7.5%) / 821 s (-5.0%)
> - wall: 113 s / 105 s (-7.1%) / 105 s (-7.1%)
>
> Clean local repository (master / change / change + #2379):
> - allocated: 404.2 GB / 302.2 GB (-25.2%) / 300.2 GB (-25.7%)
> - young GC: 429.5 GB / 326.2 GB (-24.1%) / 325.1 GB (-24.3%)
> - CPU: 853 s / 803 s (-5.9%) / 850 s (-0.4%)
> - wall: 384 s / 378 s (-1.6%) / 409 s (+6.5%)
>
> Trust the allocation numbers most: they vary by less than 1.5 GB
> within a variant. CPU and wall time swing
> by 40–60 s between runs. With a warm repository, master took 110–115 s
> wall and the change 99–109 s. Every
> run resolved the same number of artifacts. Once the filter only runs
> on local misses, #2379 has little left
> to save; on its own it saves 5–6 % of allocation.
>
> If the current order isn't a hard requirement, I'd be glad to open a
> PR. If it is, a config property that
> picks the order would work for us too. I'm happy to share the patch
> and the benchmark extension.
>
> --
> Alexander Bubenchikov
> Software developer
> JetBrains
> http://www.jetbrains.com
> The Drive to Develop
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to