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

Faster bottom up algorithm based on faster-greedy-dag #20

Merged
merged 4 commits into from
Dec 13, 2023

Conversation

oflatt
Copy link
Member

@oflatt oflatt commented Dec 5, 2023

@TrevorHansen's optimization using parent pointers also makes the bottom up algorithm without sharing faster

cumulative time for bottom-up: 2509ms
cumulative time for faster-bottom-up: 1930ms

Copy link
Contributor

@ezrosent ezrosent left a comment

Choose a reason for hiding this comment

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

Minor comments.

src/extract/faster_bottom_up.rs Show resolved Hide resolved
src/extract/faster_bottom_up.rs Show resolved Hide resolved
src/extract/faster_bottom_up.rs Outdated Show resolved Hide resolved
}
}

/** A data structure to maintain a queue of unique elements.
Copy link
Contributor

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?

Copy link
Member Author

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.

costs.insert(class_id.clone(), cost);
analysis_pending.extend(parents[class_id].iter().cloned());
}
} else {
Copy link
Contributor

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?

Copy link
Member Author

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

@oflatt oflatt requested a review from ezrosent December 11, 2023 23:30
@oflatt oflatt merged commit c9239c2 into egraphs-good:main Dec 13, 2023
2 checks passed
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.

2 participants