Skip to content
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

String interning #3927

Open
marselester opened this issue Oct 20, 2023 · 3 comments
Open

String interning #3927

marselester opened this issue Oct 20, 2023 · 3 comments

Comments

@marselester
Copy link
Contributor

Have you already considered string interning to reduce memory consumption?

I am aware of several approaches:

It looks like Thanos got good results with go4org/intern thanos-io/thanos#5926, though I am not sure if it's ok to intern like that intern.GetByString(s).Get().(string) go4org/intern#19.

See also Optimizing string usage in Go programs slides.

@metalmatze
Copy link
Member

While we can certainly work towards improving the usage of strings, I don't see it being the highest contender for further improvements in Parca itself right now: https://pprof.me/a2522ef
Having said that, if someone wants to work on this, I don't think anyone is going to be opposed to merging those changes!

@marselester
Copy link
Contributor Author

Sounds good! It would be better to compare a memory footprint (resident set size) with and without string interning (i.e., storing only one copy of a string) on production where Parca receives lots of duplicate strings (labels, symbols). From what I understand, we won't see any difference in a heap profile; at least I didn't see a difference in benchmarks, but RSS and the size of structs that held interned strings were smaller (measured with github.com/DmitriyVTitov/size).

Screenshot 2023-10-30 at 18 56 32

@kakkoyun
Copy link
Member

kakkoyun commented Nov 6, 2023

There are some discussions on adding a package to stdlib golang/go#62483

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants