-
Notifications
You must be signed in to change notification settings - Fork 38
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: fewer intersections in satisfier #174
Conversation
This is quite the list of changes. I've made a first read pass. Most of things seem ok, but I was very skeptic about what I read here 2ee7c08. Implications (=>) is not equivalence (<=>). I'll have to re-read all that at a more reasonable hour. |
6e72a2b
to
8b6852f
Compare
I made such a long list of changes so that it would be easy to call out exactly where I had made an incorrect leap of logic. That does seems suspicious. I am comforted by the assertion passing, but that doesn't mean I can prove it's valid. ... Speaking of the assertion, I used I'm going to set the prop tests to keep running overnight, and see if they found anything by the morning. |
So here's the way I'm thinking about it at the moment, there are four kinds of versions. A version can either be contained in
(Edit: Now that I have fixed my mistakes) It looks to me like it is correct. |
8b6852f
to
5ca8972
Compare
Having run the prop tests overnight, they still haven't found anything. |
That's great! I'm taking some family time for the end of year so probably won't have a more in-depth review of this until the new year. I'd like to review this more in depth, but don't want to be a big blocker if you have a lot more planned during this period. |
Please enjoy your holidays with no stress from this project. I suspect you will not be the only one with limited time to look at this. (I'm very excited to see how much difference this makes on the non-synthetic cases, but I must be patient.) |
I discussed this with a mathematician friend tonight. I believe the transformation is correct, and is easier to understand starting a little further back. (Utilizing the shorthand |
5ca8972
to
8b6852f
Compare
46d783d
to
e60b6be
Compare
previous_satisfier_level, | ||
}; | ||
(satisfier_package, search_result) | ||
let search_result = if previous_satisfier_level >= satisfier_decision_level { |
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.
The >=
is a bit weird to read for "same decision level" no? shouldn't it be ==
? I might have forgotten but the search starts at the same decision level right? so it could not go >
?
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, I believe ==
would also be correct. The re-factoring tool gave me >=
when flipping the if as a simplification of !(previous_satisfier_level < satisfier_decision_level)
. How should we leave it?
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'm going to call it defensive coding, and if we change our mind PR's are cheap.
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.
Ok, sounds good
Thanks for that! |
e60b6be
to
a890799
Compare
This is some "straightforward" re-factoring to the satisfier code to take advantage of #171. This is not my first time following this line of inquiry. In previous attempts I have only saved the final solution, and then not been confident that the final solution had the same semantics as the original. So this time I kept a separate commit for each transformation. I also kept the original code around with debug asserts to make sure they had the same behavior. Each commit passes all tests. I would strongly recommend reviewing this one commit at a time, and looking at the commit message for why I thought it was correct.
Some highlights: 1299c67 goes from 2 intersections to 1 for each decision searched in the history. 5127437 goes from a linear to a logarithmic scan. 78f8fb1 and the commits that follow are just things I noticed while staring at this code and can be left for follow-up PRs if their controversial.
As for performance the normal benchmarks think this is lost in the noise. Because they don't do much backtracking and intersection is fairly cheap. The new synthetic benchmark
slow_135_0_u16_NumberVersion
improves its runtime by 82%!