28.11.11

Biased Locking, OSR, and Benchmarking Fun | Javalobby

Biased Locking, OSR, and Benchmarking Fun | Javalobby

Java Lock Implementations
Dr. Cliff Click's Blog | Azul Systems
What the heck is OSR and why is it Bad (or Good)? by Dr. Cliff Click | Azul Systems: Blogs
A short conversation on Biased Locking by Dr. Cliff Click | Azul Systems: Blogs

  • In the last post I concluded, based on my experiments, that biased locking was no longer necessary on modern CPUs. 
  • it was not valid because the experiment did not take account of some JVM warm up behaviour that I was unaware of.
  • Cliff Click pointed out that it is much harder for a runtime to optimise a loop part way through, and especially difficult if nested.  For example, bounds checking within the loop may not be possible to eliminate.
  • Dave Dice pointed out that Hotspot does not enable objects for biased locking in the first few seconds (4s at present) of JVM startup.
  • -XX:BiasedLockingStartupDelay=0
My (Martin's) tests in the last post are invalid for the testing of an un-contended biased lock, because the lock was not actually biased.  If you are designing code following the single writer principle, and therefore having un-contended locks when using 3rd party libraries, then having biased locking enabled is a significant performance boost.

No comments: