Tuesday, July 21, 2015

VM options for optimization (C1 and C2 compilers)

Many Java Developers often ask what are the flag options available for C1 and C2 Compilers or what are the flag options available for JIT compilers. Though most of the time our slides will cover some of the important VM options (-XX) but certainly we can't  provide the list of complete option in slides. This is actually quite a trivial job.
Here it goes:
1. Complete VM global flag option (redirecting it to out file):
java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal > out
wc -l < out
764  // Total available options, did on jdk7
2. If you will check without  UnlockDiagnosticVMOptions, the no.s will be bit less.
java  -XX:+PrintFlagsFinal > out
wc -l < out
2. This document comes with the beautiful option of where it is been used like Product, C2 diagnostic, C1 Product and many more. So, just grep the out file with "C2" and see what options are available for you on C2 Compiler and which options are product options and which are diagnostic or logging options.
 cat out | grep "C2"  (Linux/Solaris/Mac machine option, find the equivalent to windows)
A list will come something like:
     intx AliasLevel                                = 3               {C2 product}
     bool AlignVector                               = true            {C2 product}
     intx AutoBoxCacheMax                           = 128             {C2 product}
     bool BlockLayoutByFrequency                    = true            {C2 product}
     intx BlockLayoutMinDiamondPercentage           = 20              {C2 product}
     bool BlockLayoutRotateLoops                    = true            {C2 product}
     bool BranchOnRegister                          = false           {C2 product}
     intx ConditionalMoveLimit                      = 3               {C2 pd product}
     bool DebugInlinedCalls                         = true            {C2 diagnostic}
ccstrlist DisableIntrinsic                          =                 {C2 diagnostic}
     bool DoEscapeAnalysis                          = true            {C2 product}
     intx DominatorSearchLimit                      = 1000            {C2 diagnostic}
     intx EliminateAllocationArraySizeLimit         = 64              {C2 product}
     bool EliminateAllocations                      = true            {C2 product}
     bool EliminateAutoBox                          = false           {C2 diagnostic}
     bool EliminateLocks                            = true            {C2 product}
     bool EliminateNestedLocks                      = true            {C2 product}
     bool IncrementalInline                         = true            {C2 product}
     bool InsertMemBarAfterArraycopy                = true            {C2 product}
     intx InteriorEntryAlignment                    = 16              {C2 pd product}
     intx LiveNodeCountInliningCutoff               = 20000           {C2 product}
 3. Running the same option for C1.
cat out | grep "C1" 
We can see:
     bool C1OptimizeVirtualCallProfiling            = true            {C1 product}
     bool C1ProfileBranches                         = true            {C1 product}
     bool C1ProfileCalls                            = true            {C1 product}
     bool C1ProfileCheckcasts                       = true            {C1 product}
     bool C1ProfileInlinedCalls                     = true            {C1 product}
     bool C1ProfileVirtualCalls                     = true            {C1 product}
     bool C1UpdateMethodData                        = true            {C1 product}
     intx CompilationRepeat                         = 0               {C1 product}
     bool LIRFillDelaySlots                         = false           {C1 pd product}
     intx SafepointPollOffset                       = 256             {C1 pd product}
     bool TimeLinearScan                            = false           {C1 product}
     intx ValueMapInitialSize                       = 11              {C1 product}
     intx ValueMapMaxLoopSize                       = 8               {C1 product}
 Enjoy Optimization, Enjoy JIT'ing.

No comments: