-
Notifications
You must be signed in to change notification settings - Fork 181
Push Pop API #300
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
Draft
dewert99
wants to merge
21
commits into
egraphs-good:main
Choose a base branch
from
dewert99:semi-persistent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Push Pop API #300
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…and `analysis_pending`
11544ea to
2c1c95f
Compare
e4a8f32 to
da807b0
Compare
# Conflicts: # src/egraph.rs # src/raw/egraph.rs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another attempt at #290 that builds on #296.
I first added a
push/popAPI toRawEGraphthat depends on an additional generic parameter. I ended up with two implementation strategies, and as I wasn't sure which one was better I implemented both, the generic parameter can also be instantiated with()to disablepush/popstatically, orOptionto do it dynamically. Thepushfunction forRawEGraphreturns aPushInfowhich needs to be passed intopopso that the API can compose better with other similar APIs without each one needing its onVec<PushInfo>.While I was working on this implementation I noticed that I could easily make
memoappend-only by having it nodes to the firstIdthat is congruently equivalent instead of the most recent one. My first thought was to convertmemointo anIndexMapso it could be reverted by callingpopuntil it reached its old size. Unfortunately I noticed this had slightly worse performance than aHashMap. Instead I implemented my ownDHashMapusing ahashbrown::HashTable, it has performance characteristics similar to aHashMapbut it stores the insertion order index along with each key/value pair. This allows it to efficiently remove the last element (given it's hash value). It can also iterate in insertion order, but this is more expensive thatIndexMapand requires allocation.I added⚠️ ) since
pushandpoptoEGraphand made it controlled dynamically withwith_push_pop_enabledandwith_push_pop_disabled(similar to explanations). I currently added a feature to pick between the two implementations I created, although it might make more sense just to pick one. These methods requireN::Data: Defaultso I could temporarily have classes without data without making it anOptionorMaybeUninit. I neededN::Data: Cloneso I could keep a log of copies old versions to revert to duringpop. Unfortunately I had to make this a bound inAnalysis(Breaking changecloneis called inunionandset_analysis_data(notpushorpop).To test the new API I added a
test-push-popfeature (similar totest-explanations) that also adds a hook to callpushand make a clone of theEGraphat each iteration. Afterwards it repeatedly callspopand each times checks if theEGraphmatches its corresponding clone.