Skip to content

Speedup dependency resolver by pre-cutting unsolvable branches #14

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

Merged
merged 1 commit into from
Apr 7, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Apr 7, 2023

This change speed up cases where a lot of dependencies are present but one is missing:

A
|__ B (1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4)
|__ C (1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4)
|__ D (1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4)
|__ E (1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4)
|__ F (1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4)
|__ G (1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4)
|__ H (1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4)
\__ I (dependency not available)

In this case the last dependency I can not be resolved, but it is checked as last. This means that the backtracking algorithm will check all the other branches first with exponential time complexity (in the case shown above it must check 5^7 combinations before giving up).

@cmaglie cmaglie self-assigned this Apr 7, 2023
@cmaglie
Copy link
Member Author

cmaglie commented Apr 7, 2023

See arduino/arduino-cli#2135 for a real-world use case

@codecov
Copy link

codecov bot commented Apr 7, 2023

Codecov Report

Merging #14 (1e9020d) into master (9dd7f57) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #14   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          804       815   +11     
=========================================
+ Hits           804       815   +11     
Impacted Files Coverage Δ
resolver.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@cmaglie cmaglie merged commit df298c3 into master Apr 7, 2023
@cmaglie cmaglie deleted the speedup_leaf_backtracking branch April 7, 2023 13:19
@per1234 per1234 added the enhancement New feature or request label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants