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

Add search_with_limit #197

Merged
merged 4 commits into from
Aug 3, 2022
Merged

Conversation

yihozhang
Copy link
Contributor

@yihozhang yihozhang commented Jul 8, 2022

Currently, the BackoffScheduler will search each pattern, and if the match size is larger than the threshold, all the matches will be threw away and the rule will be banned. However, rules like AC will take an intractable amount of time and find ridiculously many matches, even when the threshold is small.

This PR tries to add an interface for search_with_limit and search_eclass_with_limit, while being compatible with the existing interface. With this PR, the e-matching machine will stop searching as soon as the number of matches hits the limit.

@yihozhang yihozhang marked this pull request as ready for review July 11, 2022 20:07
src/rewrite.rs Outdated
@@ -128,7 +166,34 @@ where
{
/// Search one eclass, returning None if no matches can be found.
/// This should not return a SearchMatches with no substs.
fn search_eclass(&self, egraph: &EGraph<L, N>, eclass: Id) -> Option<SearchMatches<L>>;
///
/// Implementation of [`Searcher`] should implement one of
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I appreciate the effort to not break the API, but this could be a little confusing because the "default" behavior is an infinite loop! I think we should require search_with_limit.

@yihozhang
Copy link
Contributor Author

I've removed the default implementation of search_with_limit @mwillsey

@mwillsey mwillsey merged commit ae8af88 into egraphs-good:main Aug 3, 2022
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