-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Implement sharing for hls-graph Keys #3206
Conversation
dc5cf30
to
3645961
Compare
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.
Approved. Please share some benchmarks showing the memory savings when you have a chance!
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.
Can we drop the Int
proxy (Key
) and the IntMap
?
newKey
will lookup in the KeyMap
and return the existing value if any, recovering sharing.
What's the benefit of keeping an extra mapping?
I tried this first, but GHC unpacks the Key and we lose sharing at that point. |
Worth adding a comment about this, I believe my previous attempt to share keys must have failed for this reason |
Maybe it's a bit too sensitive, but can we do something to prevent GHC from unpacking the key? e.g. not import the constructor in the module in question? |
I don't think this is possible currently. Would be a good feature request though. |
I've also added sharing of the rendered |
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.
Can we have those benchmark results?
c3ab732
to
5ef5975
Compare
15b21a9
to
1311c87
Compare
1311c87
to
b426e44
Compare
On large projects, duplicate Keys start to comprise a significant (~5-10%) fraction of the heap.
This becomes better if we use
Int
s as keys and de-duplicate the actual values by storing themin maps.
Key
s are mostly just compared and hash during usual operation, printing them out israre so a lookup shouldn't pessimize it much.
Also use HashSets to keep track of dependencies.
However, this means that the underlying value for
Key
s will never be garbage collected once allocated.