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

fix: skip deep dependency comparison for Gradle projects #9817

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jjohannes
Copy link
Contributor

This is unnecessary and leads to a long runtime (and possible an infinite loop/recursion) for large dependency graphs as observed in #9763.

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.05%. Comparing base (7c63104) to head (05b57b9).

Files with missing lines Patch % Lines
...el/src/main/kotlin/utils/DependencyGraphBuilder.kt 20.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9817      +/-   ##
============================================
- Coverage     68.07%   68.05%   -0.03%     
  Complexity     1285     1285              
============================================
  Files           249      249              
  Lines          8828     8831       +3     
  Branches        918      919       +1     
============================================
  Hits           6010     6010              
- Misses         2432     2434       +2     
- Partials        386      387       +1     
Flag Coverage Δ
funTest-non-docker 33.33% <0.00%> (-0.02%) ⬇️
test-ubuntu-24.04 35.89% <20.00%> (-0.02%) ⬇️
test-windows-2022 35.87% <20.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sschuberth sschuberth force-pushed the gradle-graph-buillder-quick-fix branch from a3c19f7 to 86d09b3 Compare January 23, 2025 17:32
@sschuberth sschuberth marked this pull request as ready for review January 23, 2025 17:32
@sschuberth sschuberth requested a review from a team as a code owner January 23, 2025 17:32
@sschuberth sschuberth enabled auto-merge (rebase) January 23, 2025 17:32
sschuberth
sschuberth previously approved these changes Jan 23, 2025
@sschuberth
Copy link
Member

There are some test differences to inspect.

@sschuberth
Copy link
Member

There are some test differences to inspect.

For whatever reason, the change causes a lot of the following differences in the dependency tree:

image

It basically seems that cycles are now cut too early or so.

@sschuberth
Copy link
Member

It basically seems that cycles are now cut too early or so.

Or actually, it seems that runtime dependencies are omitted now. Take a look at e.g. lifecycle-livedata-core:2.5.0:

image

core-common:2.1.0 and core-runtime:2.1.0 are exactly the omitted direct dependencies.

sschuberth and others added 2 commits January 23, 2025 23:08
This makes the diff, if any, to expected results more readable.

Signed-off-by: Sebastian Schuberth <[email protected]>
This is unnecessary and leads to a long runtime (and possible an
infinite loop / recursion) for large dependency graphs as observed in

Signed-off-by: Jendrik Johannes <[email protected]>
@sschuberth sschuberth force-pushed the gradle-graph-buillder-quick-fix branch from 86d09b3 to 05b57b9 Compare January 23, 2025 22:08
val dependencies2 = dependencies.associateBy { dependencyHandler.identifierFor(it) }
if (!dependencies2.keys.containsAll(dependencies1)) return false

if (dependencies1 == dependencies2.keys) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that no "GradleDependencyHandler" specific code must be put here.
Instead we should provide means to inject / override the equality comparison function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extending the DependencyHandler interface with such a function is a good idea; however, it currently is unclear how to proceed further with the test failures. @jjohannes and I will look into them again later.

val dependencies2 = dependencies.associateBy { dependencyHandler.identifierFor(it) }
if (!dependencies2.keys.containsAll(dependencies1)) return false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, @oheger-bosch do you recall why the original code uses an "uni-directional" containsAll() here? In other words, why did we continue here if dependencies2 was a superset of dependencies1, instead of also returning false early?

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 this pull request may close these issues.

3 participants