-
Notifications
You must be signed in to change notification settings - Fork 34
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
Proptest index #28
Proptest index #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't properly read everything in details yet but this looks amazing!
#[should_panic] | ||
fn callback_can_panic() { | ||
let mut dependency_provider = OfflineDependencyProvider::<_, NumberVersion>::new(); | ||
dependency_provider.add_dependencies(0, 0, vec![(666, Range::any())]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahahah good one
tests/proptest.rs
Outdated
})] | ||
|
||
#[test] | ||
/// This test is mostly for profiling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it uses strings for package ids right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It was one of the first tests I wrote after getting registry_strategy
working. It may no longer be pulling its weight. I wanted to compare a profile with expensive clones vs one with cheap clones. The other use the faster version ids to not waste CI time, but I want something to test that we are not cloning way way to much. I am open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to still have a strings example in my opinion, to be closer to real usage when benchmarking things that depend on hash maps. If it's not needed on CI though, is there a way to deactivate a bunch of tests specifically when on CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is always if std::env::var("CI").is_ok() {return;}
. If it is still worth running then I am ok running on CI. When CI is a bottleneck we can revisit.
for (name, ver) in cases { | ||
let one = resolve(&TimeoutDependencyProvider::new(dependency_provider.clone(), 50_000), name, ver); | ||
for _ in 0..3 { | ||
match (&one, &resolve(&TimeoutDependencyProvider::new(dependency_provider.clone(), 50_000), name, ver)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that the difference is not due to the timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, In Cargo we do not have fine grained control over the timeout. So I have not yet thought about how to take advantage of the better controls here.
tests/proptest.rs
Outdated
for (name, ver) in cases { | ||
if resolve(&dependency_provider, name, ver).is_ok() { | ||
prop_assert!( | ||
resolve(&TimeoutDependencyProvider::new(dependency_provider.clone(), 50_000), name, ver).is_ok(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should removing dependencies also ensure shorter runs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a really good thought. That is a thing I did not think to test when working on Cargo as it is not flexible like that. Do you think we should work on it in this PR or in a follow up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, jut a thought I had but it's not correct. A missing dependency could generate an incompatibility that later reduces potential packages. But we should check that the difference, if there is one, is not due to timeouts I think.
52534be
to
5e35146
Compare
if resolve(&TimeoutDependencyProvider::new(dependency_provider.clone(), 50_000), name, ver).is_ok() { | ||
prop_assert!( | ||
resolve(&TimeoutDependencyProvider::new(removed_provider.clone(), 50_000), name, ver).is_ok(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally don't want to resolve
on a generated dependency_provider
without some kind of timeout. It is frustrating when CI fails with "terminated do to no output in 10 min" with no info on what input is slow. (looks like that limitation may have been from my Travis days, Github Actions may not have that limitation, but a hang is also frustrating.
What behaviour do you think the test should have when one of these hangs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probable that those two won't take the same amount of time and it's not what this test tries to ensure, so if at least one of the two resolve
timeouts the test should pass in my opinion. Passing or not passing that test will be much more correlated to the shape of index than to its size if there is an issue somewhere. In fact it would make sense to have different registry strategies, of different sizes and shapes, but that can be explored later.
Concretely, we can let it fail for now. Gather the examples when it fails to rerun them locally and figure if those are true failures. When a few of these happen we can see if it's worth continuing to fail or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will definitely have to work on all of these tests, to ensure they maintain a good signal to noise ratio. If they turn out not to pull their weight, we can alter or remove!
Just to clarify are you ok with merging as is?
5e35146
to
fceb5ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work, thanks @Eh2406 !
The only thing I haven't spent time to look at closely is the proptest strategy to generate the index. I'll look at it later when I have time since this is obviously giving us good examples such as the ones we used for benchmarks.
Good to merge in my opinion, just waiting for @aleksator feedback
Oh I had one remark actually that I forgot. The name |
I added some proofreading commits and renamed I've noticed there are a few unresolved discussions started by @mpizenberg (like |
I interpret "Good to merge in my opinion, just waiting for @aleksator feedback" as a yes. I like @aleksator's renames. I see the point about the name Also do we want that callback to take an argument in case we have diagnostics we can share about the progress? |
We can improve the callback API later, for now let's just find a more descriptive name and merge this. What do you think of |
That works! |
Maybe |
Some other suggestions: Maybe we should discuss this on Zulip 😄 |
d0f72c1
to
bff9acd
Compare
rebased and updated the name to |
Any remarks left @aleksator ? |
damn I wasn't fast enought XD. Thanks @aleksator and amazing work @Eh2406 ! |
That's good, because I managed to edit commit messages 😋
Maybe we should have separated a timeout feature from proptest port. I realized that when I was adding a conventional commit label: it contained both
Agree! 👍 |
This is mostly porting proptests from Cargo. It is mostly ready for a first PR.
Things that have been intentionally left for a follow up:
dependency_provider
that was used.Ok(_)
output has all its dependencies satisfied.Err(_)
output happens when an SAT solver also can't find a solution.This is going to be unpleasant unless we:
Impl a time out. So inputs that leave us in an infinite loop (or effectively infinite) just come out as a panic.CC discussion on zulipSome way to make sure the slow job of shrinking does not happen on CI. (not hard but I need to do it.)Just wanted to share for others to take a look.