-
-
Notifications
You must be signed in to change notification settings - Fork 48
Fix enode memoization #238
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
Closed
Closed
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4d24031
Fix check_memo() to match egg, and activate check_memo() assertion te…
gkronber 59718eb
Remove unused code.
gkronber e4a3f03
Remove caching of hash values in VecExpr.
gkronber 2677542
Improve lookups in g.memo to search only once (call get(), instead of…
gkronber c5c4776
Test check_memo() again for running tests. Now the assertions hold an…
gkronber de83bd9
Simplify code.
gkronber 9f504fe
trigger on all branches
a606a15
Merge remote-tracking branch 'origin/master' into fix_enode_memoization
gkronber 29890ce
always run CI
8e95e4a
add column
c398f31
Merge remote-tracking branch 'origin/master' into fix_enode_memoization
gkronber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the hash going to mutate as well? What is the difference from caching it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, the main issue is that VecExpr must not be updated after they have been added to memo. Caching of hash values is an independent concern.
I did a quick analysis, in which I checked how often the cached values are actually used and I saw only a small usage factor. I'll redo the analysis more carefully and post the result here.
The cached value can make up 15% to 20% of the memory required for VecExpr.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the annotations in https://github.com/gkronber/Metatheory.jl/tree/count_vecexpr_hash_calls
(gkronber@593d9e2)
In this run of the benchmarks:
VecExprobjects are constructed (some via v_new, some via copy, most via direct constructor calls)haskey(n) && g.memo[n]).g.memo[n]is set (memo_add)hash(n::VecExpr)v_hash!is called 42mio times (40.7mio times the hash value is calculated, 1.2mio times the cached value is returned)haskey(n) && g.memo[n]we usegetwe should be able to reduce the number of hash calls significantly (exact number to be added in a later edit).hash(n::VecExpr). The other numbers are unchanged. We still need to calculate the hash 40.7mio times. (65346c7)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this happens as well in
eggand is part of the algorithm. We should ask the egg community how they are doing it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In egg they are careful to clone nodes before adding them to memo.