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

is_backtrack_cause is very expensive to evaluate #10620

Open
1 task done
jbylund opened this issue Oct 28, 2021 · 0 comments
Open
1 task done

is_backtrack_cause is very expensive to evaluate #10620

jbylund opened this issue Oct 28, 2021 · 0 comments
Labels
C: dependency resolution About choosing which dependencies to install type: feature request Request for a new feature type: performance Commands take too long to run

Comments

@jbylund
Copy link
Contributor

jbylund commented Oct 28, 2021

What's the problem this feature will solve?

The provider's is_backtrack_cause method is currently pretty expensive to evaluate (44% inclusive, profile)

@staticmethod
def is_backtrack_cause(
identifier: str, backtrack_causes: Sequence["PreferenceInformation"]
) -> bool:
for backtrack_cause in backtrack_causes:
if identifier == backtrack_cause.requirement.name:
return True
if backtrack_cause.parent and identifier == backtrack_cause.parent.name:
return True
return False

Conceptually it's "is this identifier in this set of names & parent's names", but because it drives a sort (in part) we scan the entire list many times (additionally, the .name property of some of these objects is expensive).

Describe the solution you'd like

I'd like to implement is_backtrack_cause in a way that we can ask identifier in constant_time_lookup_datastructure. Draft of an idea in #10621.

Alternative Solutions

I looked at implementing this in resolvelib a little bit, but my impression is that resolvelib doesn't want to be so opinionated about what these objects are?

Code of Conduct

@jbylund jbylund added S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature labels Oct 28, 2021
@ichard26 ichard26 added C: dependency resolution About choosing which dependencies to install type: performance Commands take too long to run and removed S: needs triage Issues/PRs that need to be triaged labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: dependency resolution About choosing which dependencies to install type: feature request Request for a new feature type: performance Commands take too long to run
Projects
None yet
Development

No branches or pull requests

2 participants