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

perf: choose package with fewest versions matching (30x speedup) #32

Merged
merged 2 commits into from
Oct 12, 2020

Conversation

Eh2406
Copy link
Member

@Eh2406 Eh2406 commented Oct 10, 2020

This adds the heuristic that is described in the comment. This is the heuristic asked for in #20, but there may be even better ones to try. Unfortunately, it is hard to tell with the existing benchmark as even this makes the benchmark fly. For me the benchmark 0.175 sec -> 0.006 sec!

src/term.rs Outdated Show resolved Hide resolved
.potential_packages()
.next()
.map(|(p, all_terms)| (p.clone(), Term::intersect_all(all_terms.iter())))
.map(|(p, all_terms)| (p, Term::intersect_all(all_terms.iter())))
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a very pricey thing to do if we effectively iterate over all potential packages. In such case, it would probably be worth keeping in memory not a Vec of derivations but their intersections directly. I haven't reread the code but I think we may never need individual derivations for anything. Every usage we have of Memory could be as efficient or more if we actually had the intersection directly.

To be checked

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, That is definitely worth looking into! But with this already being 30x it is hard to tell based on this benchmark. It seams to worth committing now and evaluating that again when we have a new benchmark.

Copy link
Member

Choose a reason for hiding this comment

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

Alright!

@mpizenberg
Copy link
Member

mpizenberg commented Oct 11, 2020

0.175 sec -> 0.06 sec!

Did you mean 3x speed up then? XD

@Eh2406
Copy link
Member Author

Eh2406 commented Oct 11, 2020

No, sorry typo. I ment 0.006. 😄

Copy link
Member

@mpizenberg mpizenberg left a comment

Choose a reason for hiding this comment

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

All good to me! If that's ok with @aleksator too?, let's merge

@aleksator
Copy link
Member

aleksator commented Oct 12, 2020

I've added a small doc change to the pick_package function to improve the grammar and remove todo that asks to improve the function. We may never find a better heuristic, so it's unclear what would be the next best time to remove it if not now. And if we do improve, the change would be guided by benchmarking and todo wouldn't help finding it.

@aleksator aleksator merged commit 007f34a into dev Oct 12, 2020
@Eh2406 Eh2406 deleted the better-heuristic branch October 12, 2020 21:02
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.

None yet

3 participants