-
Notifications
You must be signed in to change notification settings - Fork 139
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
Extracted out RawEGraph
type
#296
base: main
Are you sure you want to change the base?
Conversation
…and `analysis_pending`
Cool! Just so I understand, what is the overall motivation here? Is this to reduce complexity in the current implementation? Or is there a particular use-case/feature that you are looking to support? |
The main motivation is flexibility, currently anyone using A potential side benefit is that with the core egraph abstracted away it may be less costly to revisit something like #284 |
This looks like an interesting refactor. Is one of the motivations of this PR to support multiple or composable Analysis? |
Partially, my idea was to have a flexible lower-level plain egraph, that doesn't do extra work, (eg. managing explanations, keeping track of nodes in each class, managing a lattice based analysis (although this could already be turned off)). My specific motivation was https://github.com/dewert99/bat_egg_smt, a toy QF_UF. It uses a different strategy for explanations, and doesn't need to store a list of nodes in each eclass so I didn't want the overhead of a full
I haven't looked as closely at |
Very cool! I'll be interested to see how you implement explanations and how the solver performs. Egglog might have different performance characteristics, though it's usually faster than egg for a few reasons. Currently it doesn't have parent pointers, explanations, or uncanonical ids. |
When you say that it doesn't have uncanonical ids, do you mean that it doesn't have store the original node for each uncanonical ids, and how does rebuilding work without parent pointers? |
My original explanation implementation was similar to Recently I tried switching to a different implementation based on https://www.cs.upc.edu/~oliveras/rta05.pdf "2.1 Union-find with an O(k log n) Explain operation" which seemed to give a minor performance benefit. |
Yeah, it doesn't store the original node for uncanonical ids. Rebuiding works basically by running a query. For example, rebuilding all
The query finds Add nodes that differ in the eclass they belong to. It then makes them equal. I think egglog's rebuilding is eggs as a result, and timestamps help it only find new matches to this query. |
That's the paper I used to implement egg's |
Sorry if I'm missing something, but if the database had |
Since I was only interested in the oldest proofs, I didn't want the overhead of keeping |
Good point! The indices that we build for queries are like parent pointers. |
Is there a way to make the current implementation in egg as performant as yours when explanation optimization is disabled? |
Probably not without making the explanation a generic/type parameter of |
Now that #291, has been merged, I was wondering if you would consider merging this, in which case I would try and resolve conflicts. Otherwise, I will probably keep my fork mostly separate, maybe trying to upstream any optimizations. |
I am currently thinking that it is not worth the increased complexity. Given that there isn't a ton of active development on egg, I'm really thinking we should prioritize simplicity. I do however like the idea of one day supporting DB-like matching in egg, but I'm not sure about this architecture. Happy to discuss further though! |
Do you have any suggestions about how to improve the architecture? |
No. I’m not sure about any new architecture for egg just yet. I’m open to
suggestions, but currently I don’t quite see the benefits these changes
would bring to make it worth the additional code.
…On Mon, Apr 8, 2024 at 3:28 PM David Ewert ***@***.***> wrote:
I do however like the idea of one day supporting DB-like matching in egg,
but I'm not sure about this architecture.
Do you have any suggestions about how to improve the architecture?
—
Reply to this email directly, view it on GitHub
<#296 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANTPTF7RW6UQEBHQTOZD7DY4MKXJAVCNFSM6AAAAABC4RORW2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBTG42DGOBTGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
This is another attempt with a similar motivation to #293 (It still assumes #291).
Instead of trying to work with compositional traits, I decided to extract out a
RawEGraph
type with raw versions ofadd
,union
andrebuild
that each has various hooks, and then reimplementEGraph
to useRawEGraph
in a more backwards-compatible way. I also created theEGraphResidual
type to represent what's left of aRawEGraph
without its classes, so it could still be used while mutably borrowing data from an eclass. TheEGraphResidual
type has methods likefind
,lookup
, andid_to_node
and bothRawEGraph
andEGraph
dereference toEGraphResidual
so these implementations are shared.None of the
RawEGraph
implementation ispub(crate)
, so it could be extracted into its own crate, although it depends onId
,Language
,UnionFind
, andRecExpr
so they would need to be moved as well.