• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need clarification what the term "Warming of loops" means  RSS feed

 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HotSpot FAQ:-
Warming up loops for HotSpot is not necessary. HotSpot now contains On Stack Replacement technology which will compile a running (interpreted) method and replace it while it is still running in a loop. No need to waste your applications time warming up seemingly infinite (or very long running) loops in order to get better application performance.

I am lost here. What does "Warming up a loop mean?"
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alok Pota:
I am lost here. What does "Warming up a loop mean?"

Modern JVMs do not merely interpret Java bytecodes, but neither do they just blindly compile everything in sight. Instead, they monitor how your application executes and compile just the most intensively used bits.
As I understand it, some JVMs would not replace running interpreted code by a compiled version. So what if you had a method which looped a few hundred million times and then never was executed again? The JVM would only swap in a compiled version after it had finished executing... too late. That's where the "warming up" of loops comes in. You first do a limited dummy run of the affected loop(s), long enough to prod the JVM into compiling it but short enough not to introduce too much of a delay, and only start doing real work once you're confident that the JVM has generated compiled code for all performance critical methods.
A waste of resources, obviously. So that's why loops can now be replaced by their compiled counterparts while they are running, so you don't have to "warm up" your code anymore.
- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!