Fork me on GitHub
#java
<
2021-12-16
>
oliy16:12:27

this feels like a very long shot, but has anyone found very strange behaviour related to string deduplication with jdk version over 11? short story: we were running on jdk 11 with G1 garbage collector and string deduplication, all was fine. upgraded to jdk 17 and our processes kept being killed for using too much memory. the heap was fine, but it turned out that the string deduplication table (off heap) was growing perpetually. i think it's related to httpkit usage but can't confirm. when we turn off string deduplication the heap remains stable (slightly higher than before, but stable i.e. no leaks)

Ben Sless21:12:10

I haven't seen this phenomenon, but I can say that having looked at string deduplication I came to the conclusion I shouldn't use it. Did you do it to save on memory?

oliy21:12:55

Yeah it seems like a bit of a slam dunk to save memory. We have observed it reducing a heap that was roughly 2250mb down to about 1750

oliy21:12:06

Why did you conclude you shouldn't use it?

Ben Sless21:12:41

you're saving 500mb of memory for a massive performance hit

Ben Sless21:12:47

If it saved 80-90% of your heap I'd say go ahead, for ~20% I wouldn't bother, not worth hitting a synchronized cache for every new string

oliy21:12:14

Did you measure the perf, or find an article that did? All I've seen is 'there is a cost' but as our app's GC time is so small anyway I didn't think it could be much

Ben Sless21:12:51

It's not about GC, it's about a global throttle on strings

oliy21:12:42

I thought it just adjusted some char array pointers at GC time if it found it to be a duplicate, that all string creation on young gen is unaffected (deduplication only happens on old gen)

Ben Sless21:12:01

It does. I can try digging up those articles, but it's worth to compare the throughput and not just heap space

oliy21:12:06

Interesting thank you, I'll do a bit more reading. At this point having stared at this problem for two days without making much progress I'm tempted to just turn it off to get our app stable again

Ben Sless21:12:02

You should turn on GC logs or use jfr in any case if you want to get to the root of the problem

oliy21:12:54

Yeah been doing that, NMT and GC logs and heap analysers and all the things, made my head spin a bit. The answer is probably there but I'm quite inexperienced at reading it all

oliy21:12:02

Thanks for your advice :)

Linus Ericsson10:12:50

Would it be possible to temporarily replace httpkit with clj-http or something to confirm your hypothesis? I would prioritise stability over memory in this case.