-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
1.x Cache string values to reduce memory footprint. #434
Conversation
NetflixOSS » eureka » eureka-pull-requests #114 SUCCESS |
/** | ||
* @author Tomasz Bak | ||
*/ | ||
public class StringCache { |
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.
Any reason why you are not using String.intern() simply?
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 String.intern() was technically forbidden in the past for string pool usage. This implementation of StringCache follows xstream's StringConverter which I tried to use, but since we have custom serializer it is never invoked.
I checked again, and actually in Java7 the String.intern() implementation is fixed, and it is better alternative than having own string pools, but unless running on 7u40, it requires setting -XX:StringTableSize=N to proper value (before 7u40 default = 1009, later default = 60013 which is better but we might need even higher value). Check this article: http://java-performance.info/string-intern-in-java-6-7-8/
Given that we do not control which Java7 JVM versions clients run, and we cannot enforce proper JVM configuration, sticking to own String pool implementation seems to be better option short term. Medium/long term, if we want to make similar optimization in Eureka 2.x I would go for String.intern.
Rather than implementing a StringCache independent of xstream, can't we just register a StringConverter with high priority when we register the specific converters for the JsonXStream and XmlXStream? We may also want to look at implementing an alternative to the default StringConverter similar to http://javadoc.jenkins-ci.org/hudson/util/HeapSpaceStringConverter.html. |
I tried to setup StringConverter, and my custom converter implementation, but it never got triggered. Our custom serializers do not delegate processing further once they got basic types. If you know how to enforce delegation to StringConverter it would be much nicer implementation. |
NetflixOSS » eureka » eureka-pull-requests #122 SUCCESS |
1.x Cache string values to reduce memory footprint.
No description provided.