-
Notifications
You must be signed in to change notification settings - Fork 526
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
Replace unsafe
interning with unique
package
#4264
Conversation
*pq.Value
interning with unique package
*pq.Value
interning with unique package*pq.Value
interning with unique
package
This is currently increasing the allocations. |
*pq.Value
interning with unique
packageunsafe
interning with unique
package
|
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.
Nice
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.
Nice cleanup 👍
I've reverted the drop of the intern package. A test was failing in the I've updated the package doc and renamed |
Do you have any tracesql search benchmarks? Since this loses the handle of the unique value, it means the interned values only last until the next garbage collection. Whereas the previous interner map would last as long as needed (I think cleared on each new row group). |
For reference: https://go.dev/blog/unique#a-footnote-about-interning-strings
Interested to see how the benefits look, since I'm considering doing the same for deduping span data in the generators, where a lot of duplicated span attribute data lives in the live traces map. |
What I don't like about the change currently is the lack of control about when objects are cleaned. I'd like to see if we can avoid impacting traceql. |
I'm going to take this back to draft while I work up a change I like better. |
What do you think about returning to the map-based implementation, but populate it with the unique handles? That way we keep the reference and the deduped strings are kept alive across GCs. The lifetime of the interner hasn't changed, so I think that would work very closely to the previous implementation, and let us remove the unsafe code. |
This reverts commit 76876fe.
064d96b
to
e40dfe3
Compare
I was thinking about bringing back the map also, to give us more control of the memory lifecycle. |
I don't presently understand the test failure. |
It doesn't appear to be enough to maintain the |
What this PR does:
Here we remove the use of
unsafe
from theintern
package and replace it with theunique
package. The cleanup of the internal map is now handled by theunique
package in a background go routine.Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]