Limiting saturation based on the cost function #148
-
I just discovered egg this morning and read through the tutorials quickly and skimmed the docs, but I didn't see if there is a way of limiting the rewrite search based on the cost function. As I currently understand it, egg will always go to full saturation, meaning that by the time the Runner is done the e-graph will contain all possible rewrites of a given term. However, there are times when I can tell that if a term contains a given sequence of rewrite rules that it will already be more costly to use than some other rewrite, and so there's no point in exploring further. In essence, I want to treat e-graph as a highly compressed tree, do a breadth-first search, and as soon as any path becomes expensive enough, stop searching through any tree rooted at that node. My hope is that will be somewhat more efficient that exploring the entire search space, and then extracting the best result at the very end. (BTW, I'm not a language or compiler guy, so if I'm using incorrect terminology, I apologize. I hope that the gist of what I'm trying to do make sufficient sense to you) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Typically users of egg do not run it to saturation—because that typically takes a long time, or even because they are using a set of rewrite rules where saturation never happens. (That's the situation in Herbie.) Instead you just run it for a while and extract the best when you stop. Since egg can handle pretty large e-graphs (like, about a million nodes?) that might be good enough for you. The idea of targeting rewrites based on cost is still interesting, it just probably isn't necessary for your use case! |
Beta Was this translation helpful? Give feedback.
Typically users of egg do not run it to saturation—because that typically takes a long time, or even because they are using a set of rewrite rules where saturation never happens. (That's the situation in Herbie.) Instead you just run it for a while and extract the best when you stop. Since egg can handle pretty large e-graphs (like, about a million nodes?) that might be good enough for you.
The idea of targeting rewrites based on cost is still interesting, it just probably isn't necessary for your use case!