Reduce duplicate string allocation for GC improvements#952
Conversation
jai1
left a comment
There was a problem hiding this comment.
LGTM - keeping the maximumSize or expireAfterAccess configurable will be better.
|
@rdhabalia It might be worth to just try to have the JVM do that with |
|
|
||
| public static String getReplicatorName(String replicatorPrefix, String cluster) { | ||
| return String.format("%s.%s", replicatorPrefix, cluster); | ||
| return (replicatorPrefix + "." + cluster).intern(); |
There was a problem hiding this comment.
Couldn't the string be interned also after String.format() ?
There was a problem hiding this comment.
actually I ran a test where I saw that String.format("%s%s",x,y).intern() allocates some more number of string objects than (x+"."+y).intern() when I checked with jmap -histo <pid> | grep String. However, intern() still reuses objects in both cases but somehow, String.format() adds some more instances compare to append.
|
@rdhabalia The only concern I have around |
Yes, I just targeted the main strings. We can do it for client-version as it will be small set. let me add it, |
Motivation
If broker loads 100K topics with replication enabled for them, then we see around 3M of String objects presents into heap. this contribute in gc-pause for brokers. Out of 3M strings, we saw half of them duplicate string which we can reduce.
Modifications
After checking GC roots for duplicate string:
Result
Reduce duplicate string.