What is current status of Oracle Java HotSpot VM performance options (+UseStringCache, +UseCompressedStrings, +OptimizeStringConcat)
Asked Answered
A

4

11

I was reading Java HotSpot VM Options. I've seen some interesting VM switches, mostly pertaining to Strings - which is of great value to me since my app is doing some heavy String manipulation. Those are:

  • -XX:+UseStringCache
  • -XX:+UseCompressedStrings
  • -XX:+OptimizeStringConcat

I was wondering - are these switches on by default? What is real world experience in using them? Do they make a difference?

Arborization answered 26/9, 2013 at 10:47 Comment(0)
S
6

Considering String performance, have a look at the -XX:+PrintStringTableStatistics and -XX:StringTableSize=. Java 7 comes with nice features that allow tuning of String cache when using the interned Strings. This way you can optimize the String cache size.

And, a related String Performance Q/A: Java GC tuning for strings

Seiden answered 27/9, 2013 at 0:18 Comment(0)
S
16

To check defaults use

java -XX:+PrintFlagsFinal

To find exactly what you want you can

java -XX:+PrintFlagsFinal | grep UseCompressedStrings
Sulfamerazine answered 26/9, 2013 at 10:56 Comment(1)
Thank you for this, but I was looking for a more complete answer.Arborization
C
9

I know that -XX:+UseCompressedStrings was dropped in Java 7 on the basis it was too hard to support.

For Java 7 update 40

$ java -XX:+PrintFlagsFinal 2>&1 | grep UseStringCache
     bool UseStringCache                            = false           {product}           
$ java -XX:+PrintFlagsFinal 2>&1 | grep OptimizeStringConcat
     bool OptimizeStringConcat                      = true            {C2 product}  
Chaschase answered 26/9, 2013 at 11:41 Comment(1)
I see that you posted similar question as I have last year. That basically covers what I needed to know :)Arborization
S
6

Considering String performance, have a look at the -XX:+PrintStringTableStatistics and -XX:StringTableSize=. Java 7 comes with nice features that allow tuning of String cache when using the interned Strings. This way you can optimize the String cache size.

And, a related String Performance Q/A: Java GC tuning for strings

Seiden answered 27/9, 2013 at 0:18 Comment(0)
P
6

Based on my check of JDK6u21, JDK7u21 and JDK8u191 using PrintFlagsFinal, we have the following values:

                               JDK6u21       JDK7u21       JDK8u191

-XX:+UseStringCache              false         false   <unsupported>
-XX:+UseCompressedStrings        false  <unsupported>  <unsupported>
-XX:+OptimizeStringConcat        false          true           true
Pincushion answered 31/1, 2014 at 22:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.