Profile Image
vishnupriya

What is Java Batch Mode: -Xbatch?

What is Java Batch Mode: -Xbatch? Have you used this JVM argument before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvm-argument

  • xbatch

  • batch

  • Java Batch Mode

  • -Xbatch

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:


• -Xbatch


Description:


The -Xbatch flag disables background compilation of the JVM bytecode by
Hotspot. Normally when a method is first invoked, Hotspot runs the method
immediately in interpreted mode and later compiles it to native code in order to
speed up future invocations.


Enabling the -Xbatch flag prevents compilation from occurring on a background
thread. Instead the method is compiled in the calling thread, blocking it until
complete. Then the method is actually invoked.


-Xbatch is often used in conjunction with -Xcomp, which forces immediate
compilation of each method on first invocation.


This optimisation may be relevant in batch programs where the interactive
responsiveness of the program is unimportant, or not as important as in a UI
application, for example. In a batch program only the total time taken by the
entire program is important. Serializing the compilation of methods may reduce
this total time, because less synchronization across threads is required, though
this may be at the expense of making one or more method invocations slower.


However in modern JVM implementations the -Xbatch flag is unlikely to result in
any performance gain, and may even cause a loss of performance. Therefore most
applications, including batch-style programs, should avoid using the -Xbatch
flag.


Default Value:


-Xbatch is off by default, i.e. background compilation is enabled.


Errors:


None.


Arguments Related to -Xbatch:


TODO: link to -Xcomp, -Xint

 

NOTE:


If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your
insights will help the entire 10+ million java developer community to develop
one standard source of documentation for all the JVM arguments.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvm-argument

  • xbatch

  • batch

  • Java Batch Mode

  • -Xbatch