-
Notifications
You must be signed in to change notification settings - Fork 17
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
Faster bottom up algorithm based on faster-greedy-dag #20
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.
Minor comments.
} | ||
} | ||
|
||
/** A data structure to maintain a queue of unique elements. |
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.
Why copy-paste this from the other file? Can we move it to a shared module?
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 against sharing code between these algorithms for now: I think it's good to be able to tweak them without worrying about changing the comparison.
src/extract/faster_bottom_up.rs
Outdated
costs.insert(class_id.clone(), cost); | ||
analysis_pending.extend(parents[class_id].iter().cloned()); | ||
} | ||
} else { |
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.
Why do we need this?
Right now, there's at least one child that doesn't currently have a cost. That means that at some point if we can extract this node at all we number of "unextracted children" will go from 1 to 0. At that point, this node would get re-added, no?
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.
Good point! That actually made it significantly faster!
It also made faster-greedy-dag
faster
cumulative time for faster-bottom-up: 1155ms
cumulative time for faster-greedy-dag: 1834ms
84e2215
to
0b832c3
Compare
@TrevorHansen's optimization using parent pointers also makes the bottom up algorithm without sharing faster